我有以下片段,它出现在标签中。
public class Tab3Fragment extends Fragment {
SQLiteDatabase db;
DBHandler dbHandler = new DBHandler(getContext(), null, null, 4);
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab3_frag, container, false);
db = dbHandler.getReadableDatabase();
String [] columns = {Contract.Student_Table.STUDENTS_COLUMN_ID, Contract.Student_Table.STUDENTS_COLUMN_NAME};
Cursor mCursor = db.query(Contract.Student_Table.TABLE_NAME, columns, null,
null, null, null, null);
String[] from = new String[]{Contract.Student_Table.STUDENTS_COLUMN_NAME};
int[] to = new int[]{R.id.student_view};
SimpleCursorAdapter mCurAdapter = new SimpleCursorAdapter(getContext(),android.R.layout.simple_list_item_1, mCursor, from, to,0);
ListView mMyListView = view.findViewById(R.id.simple_list);
mMyListView.setAdapter(mCurAdapter);
return view;
}
}
我有以下XML文件(tab3_frag )
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#c2f6ff"
android:orientation="vertical">
<ListView
android:id="@+id/simple_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/student_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
但是我的代码似乎不起作用,我无法发现错误。没有崩溃或错误,我的标签中没有任何内容。我很感激任何帮助我完成我可能做错事的帮助。
答案 0 :(得分:1)
是一个单独的类,用于执行所有操作。
timebase-frequency
}
答案 1 :(得分:0)
改变这个事情
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: '<CREDENTIAL_ID>', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']])
更改以下内容
为textview制作separete布局,如
list_template.xml
db = dbHandler.getReadableDatabase();
然后改变了这个东西..
<TextView
android:id="@+id/student_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />