在 Android ICS 上,我的一个 ListView 中的多项选择被破坏
我的 Android 闪存卡应用程序有一个仅在 ICS 中发生的错误。复选框的行为类似于单选按钮,就像单选按钮一样。
public class CardSetListActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.card_set_list);
ListAdapter adapter = getSimpleCursorAdapter();
// ListAdapter adapter = getArrayAdapter();
ListView list = (ListView) findViewById(R.id.listView);
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
list.setAdapter(adapter);
list.setItemsCanFocus(false);
}
private ListAdapter getSimpleCursorAdapter() {
CardsDbAdapter dbAdapter = CardsDbAdapter.getInstance(this);
Cursor cursor = dbAdapter.fetchAllCardSets();
startManagingCursor(cursor);
String[] fromColumns = new String[] { CardsDbAdapter.COL_CARD_SET };
int[] toResources = new int[] { android.R.id.text1 };
return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, cursor, fromColumns, toResources);
}
private ListAdapter getArrayAdapter() {
String[] GENRES = new String[] { "Action", "Adventure", "Animation" };
return new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, GENRES);
}
}
知道我可以在哪里寻找解决方案吗? 使用 SimpleCursorAdapter,复选框的行为类似于单选按钮。使用 ArrayAdapter,它们的行为是正确的。 我现在改用 ArrayAdapter,但仍然想知道这里发生了什么。
My android flash cards app has a bug that only occurs in ICS. The checkboxes behave like radiobuttons, like it was single-choice.
public class CardSetListActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.card_set_list);
ListAdapter adapter = getSimpleCursorAdapter();
// ListAdapter adapter = getArrayAdapter();
ListView list = (ListView) findViewById(R.id.listView);
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
list.setAdapter(adapter);
list.setItemsCanFocus(false);
}
private ListAdapter getSimpleCursorAdapter() {
CardsDbAdapter dbAdapter = CardsDbAdapter.getInstance(this);
Cursor cursor = dbAdapter.fetchAllCardSets();
startManagingCursor(cursor);
String[] fromColumns = new String[] { CardsDbAdapter.COL_CARD_SET };
int[] toResources = new int[] { android.R.id.text1 };
return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, cursor, fromColumns, toResources);
}
private ListAdapter getArrayAdapter() {
String[] GENRES = new String[] { "Action", "Adventure", "Animation" };
return new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, GENRES);
}
}
Any idea where I could look for a solution?
With the SimpleCursorAdapter, the Checkboxes behave like RadioButtons. With the ArrayAdapter they behave right.
I'm changing to use ArrayAdapter now but would still like to know what's going on here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论