android simplecursoradapter每次都出错

时间:2013-02-26 00:33:12

标签: android simplecursoradapter

我试图创建一个简单的游标适配器。我已经检查了我能找到的每个网站,以及这里的所有线程,我只是看不出有什么问题。

gcDBAssist dbHelper;
SQLiteDatabase db;
Cursor cursor;
String display;
String TAG = "Listing the database";
ListView listTimeline;
SimpleCursorAdapter adapter;

static final String[] FROM = { gcDBAssist.C_ID, gcDBAssist.C_TIME, gcDBAssist.C_SCORE, gcDBAssist.C_LEVEL, gcDBAssist.C_POSTED, gcDBAssist.C_USER };
static final int[] TO = { R.id.textID, R.id.textTime, R.id.textScore, R.id.textLevel, R.id.textPosted, R.id.textUser };

@Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);
  setContentView(R.layout.time_list);
  listTimeline = (ListView) findViewById(R.id.listTimeline);

  dbHelper = new gcDBAssist(this);
  db = dbHelper.getReadableDatabase();

}

@Override
protected void onResume() {

  super.onResume();

  //get the data
  cursor = db.rawQuery("SELECT * from " +gcDBAssist.TABLE, null);       
  adapter = new SimpleCursorAdapter(this, R.layout.row, cursor, FROM, TO, 0);
  listTimeline.setAdapter(adapter);

我运行了一些检查,我可以使用while(cursor.moveToNext())访问数据库。

0 个答案:

没有答案