HI,
I want to create multi select listview with checkbox. and also make checked = true for some of the item based on some business rule.
I can get the list view with multiple choice option working but I am not able to load some of the item as default checked when list view first loaded.
I tried using custom list adpater with following code, but its not working at all.
if (convertView == null) {
convertView = mInflater.inflate(android.R.layout.simple_list_item_multiple_choice, null);
holder = new ViewHolder();
holder.checkbox = (CheckedTextView) convertView.findViewById(android.R.id.text1);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//holder.checkbox.setChecked(true);
String mvalue = ((Item)lv.get(position)).getValue();
holder.checkbox.setText(mvalue);
if(mSelectedValues != null && mSelectedValues.length > 0) {
boolean blnSetChecked = false;
for(String s : mSelectedValues) {
if(s.equalsIgnoreCase(mvalue)) {
blnSetChecked = true;
break;
}
}
holder.checkbox.setChecked(blnSetChecked);
} else
holder.checkbox.setChecked(false);
return convertView;
I have also set follwoign property for listview after setting custom adapter.
lvList.setItemsCanFocus(false);
lvList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Please help me to get this working.
Thanks in Advance.
Sunflower.

