Updating ExpandableListView with notifyDataSetChanged()

前端 未结 3 2032
庸人自扰
庸人自扰 2020-12-20 14:49

First a short overview of my code, i hope its understandable:

  • I have a class called ToDoElement with a few variables.
  • I
相关标签:
3条回答
  • 2020-12-20 15:02

    You should call expListAdapter.notifyDataSetInvalidated()

    expListAdapter.notifyDataSetChanged() will just update your views for the new values for each items (no change in any of the elements)

    i.e it will again call your getChildView and getGroupView for each item.

    0 讨论(0)
  • 2020-12-20 15:11

    You need to add a DeleteMethod of some sort to the Adapter and remove the item from the Adapter manually, not only remove it from the List.

    Each time you refresh the the views using notifyDataSetChanged() the Adapter will call the loop around the List. Your List in the Adapter gets a null value due to the changes you made.

    0 讨论(0)
  • 2020-12-20 15:13

    Call super in your registerDataSetObserver meke notifyDataSetChanged() working well.

    @Override
    public void registerDataSetObserver(DataSetObserver observer) {
        super.registerDataSetObserver(observer);    
    }
    
    0 讨论(0)
提交回复
热议问题