如何在多种选择模式中查找已检查事件。
我使用ontemselected方法它不适合我
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,getIntent().getStringArrayExtra("agents"));
ListView list = (ListView)findViewById(R.id.ListView01);
list.setAdapter(adapter);
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
list.setSelected(true);
list.setClickable(true);
list.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Log.d("checked",""+arg2);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
答案 0 :(得分:0)
方法getcheckItemIds()
为您提供所选ID的数组
long [] checkedIDs = listviewName.getCheckItemIds();
希望这会有所帮助