我在同一行显示一个文本和一个复选框。我需要确定哪个项目已被选中。(某种与文本的关联)
setListAdapter(new ArrayAdapter<String>(this,mRowLayout,mCallerId){
@Override
public View getView(int position,View convertView,ViewGroup parent){
View row;
if (null == convertView) {
row = mInflater.inflate(mRowLayout, null);
} else {
row = convertView;
}
mText = (TextView)row.findViewById(R.id.callTitle);
final String entry = getItem(position);
mText.setText(entry);
if(mChecked != null){
mCheckBox = (CheckBox)row.findViewById(R.id.checkbox);
mCheckBox.setChecked(mChecked);
mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
if(isChecked){
if(mCheckList.indexOf(entry) != -1){
mCheckList.add(entry);
}
}else{
mCheckList.remove(entry);
}
}
});
}
return row;
}
});