0
在我的程序中我使用選項卡活動。在一個位於列表視圖的選項卡中,我嘗試從我的sqlite數據庫中獲取數據到該列表視圖。我沒有在代碼中發現錯誤,但我的列表視圖是空的。 有片段代碼:空ListView android sqlite
public static class DummySectionFragment extends Fragment implements LoaderCallbacks<Cursor>{
public static final String ARG_SECTION_NUMBER = "section_number";
public DummySectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_tracker,
container, false);
View v = inflater.inflate(R.layout.activity_tracker,
container, false);
createList();
db = new DB(act);
db.open();
String[] from = new String[] {DB.COLUMN_NAME, DB.COLUMN_TIME};
int[] to = new int[] { R.id.tvTextName, R.id.tvText_time};
Cursor cursor = db.getAllData();
scAdapter = new SimpleCursorAdapter(getActivity(), R.layout.item, cursor, from, to, 0);
lvData = (ListView) v.findViewById(R.id.lvData);
lvData.setAdapter(scAdapter);
return rootView;
}
public void createList(){
}
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLoaderReset(Loader<Cursor> arg0) {
// TODO Auto-generated method stub
}
}
這是一個愚蠢的問題;但我們必須在這裏涵蓋所有的基礎。那麼,數據庫中是否有數據? – DrkStr
是的10個元素 – kolodach