我已阅读主题
getCheckedItemCount() for API level < 11 的等价物是什么?
lv.getCheckItemIds().length
可以得到正确的检查项目的总和,
但lv.getCheckedItemIds().length
不能,为什么?谢谢!
private void InitListView(int pos) {
List<String> msgList = getSMS(pos);
ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, msgList);
lv.setAdapter(adapter2);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
SetSelectedAndTotal();
}
});
}
private void SetSelectedAndTotal(){
selectedAndTotal.setText(lv.getCheckItemIds().length + "/"+lv.getCheckedItemIds().length+ "/"
+ lv.getCount());
}