我正在开发一个简单的 Android 应用程序,它创建一个带有复选框的 ListView,如下所示
listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice,results);
this.setListAdapter(listAdapter);
ListView lv = getListView();
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
lv.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
CheckedTextView check = (CheckedTextView)view;
//The below code needed for running on AVD version 4.2
if(check.isChecked()) {
// Checkbox checked do something
}
else {
// Not checked. Do something
}
/* Exact opposite need on Samsung phone running 2.3.6
if(!check.isChecked()) {
// Checkbox checked do something
}
else {
// Not checked. DO something
} */
这真的很奇怪。当需要完全相反的检查时,应用程序将如何与两个版本兼容?
请让我知道我该如何处理。任何帮助将不胜感激。