Radiobutton State Updation After Filtering In Custom Listview
Solution 1:
You must be trying to make radiobutton checked by using position parameter of the getView() method of your adapter. Instead try to set radiobutton checked based on some Id.
EDIT:
From your code study, I came to know that you have implemented this example:
http://tokudu.com/2010/android-checkable-linear-layout/
and as I had assumed earlier, the radio button check state is dependent on position of the row in listview but not actual item in the listview whose position is meant to be changed on filter. I have done couple of changes in your code and now the listview item check is not based on position of the item, but item itself(by matching the name of contact).
Changes in the code are as follows:
HelloListViewActivity:
lv.setOnItemClickListener(newOnItemClickListener() {
@OverridepublicvoidonItemClick(AdapterView<?> av, View view, int position,
long id) {
o = av.getItemAtPosition(position);
Stringname= ((Contact) o).name;
selectedName = name;
ContactAdapter :
staticbooleanisContactChecked=false;
public View getView(int position, View convertView, ViewGroup parent) {
Viewrow= convertView;
finalContactcontact= getItem(position);
if(contact.name.equalsIgnoreCase(HelloListViewActivity.selectedName))
isContactChecked = true;
else
isContactChecked= false;
CheckableLinearLayout :
@OverridepublicvoidsetChecked(boolean checked) {
if (rb != null) {
// rb.setChecked(checked);
rb.setChecked(ContactAdapter.isContactChecked);
}
}
Post a Comment for "Radiobutton State Updation After Filtering In Custom Listview"