Change object of a listview

Asked

Viewed 425 times

0

I have a listview populated by an object, but I wanted to know if there is a way to change the object, I managed to change the view corresponding to that Object, and not to listView entire.

  • Use the notifyDataSetChanged in his Adapter will not change all objects, only the visible ones. An alternative is to set a tag View.setTag(...); to identify each View returned by Adapter in the method getView(...) and in the ListView walk the children (ViewGroup.childAt(index)) check by tag and modify the View manually.

1 answer

1

Create a method to change the list item, add conditions to capture the specific item you want to change. You need to go item by item in the list, use the for for such:

for (Object ob : listObj) { 
    if('vouAlterar'.equals(ob.getNome())) {
        ob.setNome = 'Alterei';
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.