データベースのレコードをリストビューに表示する際に問題があります。これは私のコードです
public class FirstTab extends ListActivity {
private DatabaseHelper dbhelper;
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.first);
dbhelper = new DatabaseHelper(getApplicationContext());
Cursor cursor = dbhelper.getAllNotes();
startManagingCursor(cursor);
String[] columns = new String[] {DatabaseHelper.colTitle , DatabaseHelper.colDate};
int[] to = new int[] { android.R.id.text1, android.R.id.text2};
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, columns, to);
setListAdapter(mAdapter);
}
}
と
...
public Cursor getAllNotes()
{
SQLiteDatabase db=this.getReadableDatabase();
return db.query(noteTable, new String [] {colTitle, colDesc, colDate}, null, null, null, null, null);
}
...
さらに必要な場合は、ここにレポがあります https://github.com/grzegorz-l/myHomeworks
アプリを起動すると、開始時にクラッシュします (RuntimeException)。onCreate メソッドの最後の 2 行にコメントすると実行されますが、ofc には何も表示されません。
前もって感謝します
グレッグ