1
在我的應用程序中,我有1個listview,使用arrayadapter從數據庫填充數據。Listview在Android中填充
這裏是下面的代碼:
public void onClick(View v) {
// TODO Auto-generated method stub
Cursor c = db.gethouseholdTitle();
startManagingCursor(c);
// if(cat.equals("Income"))
// {
//// System.out.println("inside if="+select);
//// Cursor cin = db.income();
String[] fromdes = new String[] {db.KEY_DATE,db.KEY_DESC,db.KEY_INCOME,db.KEY_TOTAL};
int[] todes = new int[] {R.id.text1 ,R.id.text3,R.id.text5,R.id.text7};
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.columnview, c, fromdes, todes);
// System.out.println("notes="+notes.getCount());
// setListAdapter(notes);
lv.setAdapter(notes);
}
但是示值誤差:
The constructor SimpleCursorAdapter(new View.OnClickListener(){}, int, Cursor, String[], int[]) is undefined
什麼,我在做advance.I認爲wrong.Thanks我們不能能填補點擊功能裏面光標適配器??
在onclick的背景下被改變。所以,你必須在放置'** this **'之前放置YourActivityName。提供YourActivity的背景。 – 2012-07-16 13:42:18