【发布时间】:2009-12-31 18:34:40
【问题描述】:
我正在尝试使用 ListActivity 和 SimpleCursorAdapter 根据来自数据库的查询来检查复选框。光标是问题和答案的列表。如果用户已经回答了一个问题,则应选中该复选框,但不会选中它们。代码如下所示:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.questions);
Cursor c;
testDbAdapter db = new testDbAdapter(this);
c = db.getQuestions(Long.toString(mRowId), Integer.toString(mSection));
startManagingCursor(c);
String[] from = new String[]{testDbAdapter.QUESTIONS_Q, testDbAdapter.QUESTIONS_A};
int[] to = new int[]{R.id.question, R.id.answer};
SimpleCursorAdapter results = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, c, from, to);
setListAdapter(results);
}
【问题讨论】:
标签: java android checkbox listadapter