我的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,复选框的行为类似于RadioButtons。使用ArrayAdapter,它们的行为正确。 我现在正在改变使用ArrayAdapter,但仍想知道这里发生了什么。