Skip to content Skip to sidebar Skip to footer

Listview Item Deletion Changes Item Heights

I have a ListView whose items can be deleted by swiping them. When an item is swiped, its database row gets deleted, as well as its object in the adapter's data set, and notifyData

Solution 1:

Okay, i've found a solution.

Added int lastValidPosition = -1; in the adapter, then adapter.lastValidPosition = position-1 in the deletion callback method, before adapter.notifyDataSetChanged(); , and in the getView() method of the adapter i've changed

//if(convertView ==null)
    view= inflater.inflate(R.layout.counter_list_item, null);

to

if(lastValidPosition < position | convertView == null){
    view = inflater.inflate(R.layout.counter_list_item, null);
    lastValidPosition = position;
}

and it works perfectly.

Post a Comment for "Listview Item Deletion Changes Item Heights"