我的数据库中的ListView上没有显示任何内容。 继承我的代码。 这来自收集数据的数据库连接。
public Cursor getData(String hlth_cond) {
SQLiteDatabase db = this.getWritableDatabase();
String StringQuery = "";
if(hlth_cond == "Highblood"){
StringQuery = "SELECT RECIPE_NAME FROM TBL_NAME";
}
else if (hlth_cond == "Arthritis"){
StringQuery = "SELECT RECIPE_NAME FROM TBL_NAME_Arth";
}
else if (hlth_cond == "Diabetic"){
StringQuery = "SELECT RECIPE_NAME FROM TBL_NAME_Dia";
}
Cursor res;
return res = db.rawQuery(StringQuery,null);
}
这段代码是我的主要活动
public void showList(){
String toPass="";
if(Cb_Ar.isChecked()){
toPass = Cb_Ar.toString();
}else if (Cb_Db.isChecked()){
toPass = Cb_Db.toString();
}else if (Cb_Hb.isChecked()){
toPass = Cb_Hb.toString();
}
Cursor cursor = myDb.getData(toPass);
String[] fromDb = new String[] {DatabaseHelper.RECIPE_NAME};
int[] toView = new int[] {R.id.textViewMenuSuggest};
SimpleCursorAdapter myCursor;
myCursor = new SimpleCursorAdapter(getBaseContext(),R.layout.menushow,cursor,fromDb,toView,0);
ListView myList = (ListView) findViewById(R.id.listView);
myList.setAdapter(myCursor);
}
为什么它没有显示在我的ListView上会出错?