AndroidのチェックボックスとListActivity
-
22-09-2019 - |
質問
私は、データベースからのクエリに基づいてチェックボックスに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);
}
解決
あなたは、アダプタを拡張し、bindView方法、またはコールsetViewBinderを上書きすることができます。これに対する詳細なソリューションのカップルがここに同様の質問に答えています。
所属していません StackOverflow