Listview Onclicklistner Not Working And Delete Row From Listview
list_item.xml
Solution 1:
For ListView onClickListner not working
It happens due to focusability of CheckBox
in listitem layout.
Add below line to root layout of your ListView's Item layout.
android:descendantFocusability="blocksDescendants"
in list_item.xml
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_marginTop="5dp"android:descendantFocusability="blocksDescendants">
To delete row (not sure but will work if make some changes)
for(int i=0; i < itemCount; i++){
if(checkedItem.contains(i)){
View rowView=listView.getChildAt(i) OR listView.removeViewAt(i);
listView.removeView(rowView);
//Also Remove data from **rowItems**
}
}
Here checkedItem
is arraylist(or something else) where you supposed store position of checked listrow.
Solution 2:
onClick...{
rowItems.remove(position);
notifyDataSetChanged();
}
this should work...
Post a Comment for "Listview Onclicklistner Not Working And Delete Row From Listview"