我想知道是否有办法使用简单的游标适配器同时使用自定义列表视图并允许多项选择,我目前有以下2个代码可用:
final ListView list = getListView();
list.setItemsCanFocus(false);
//list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
// initialize the adapter
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
//android.R.layout.simple_list_item_single_choice,
android.R.layout.simple_list_item_multiple_choice,
null,
new String[]{DBHelper.C_NAME},
new int[]{android.R.id.text1});
这个
Cursor cursor = dataSourceAdapter.fetchAllEntries();
// The desired columns to be bound
String[] columns = new String[] {"_id", "ASUNTO", "FECHA", "INFO"};
// the XML defined views which the data will be bound to
int[] to = new int[] {
R.id.tvID,
R.id.tvAsunto,
R.id.tvFecha,
R.id.tvInfo
};
dataAdapter = new SimpleCursorAdapter(
this,
R.layout.lvitems,
cursor,
Tasks.COLUMNS,
to,
0);
两个代码都运行正常,但我想使用我的lvitems laoyout为后者添加多项选择。
感谢您的帮助。