Remove view from MergeAdapter

后端 未结 4 1582
再見小時候
再見小時候 2021-01-06 10:29

Is it possible to remove view or adapter from MergeAdapter somehow? I\'d try to extend it and remove the view from pieces but it\'s private

4条回答
  •  被撕碎了的回忆
    2021-01-06 11:07

    Expanding on Mark Murphy's answer, I think this is as simple as adding this method to MergeAdapter:

    public void removeAdapter(ListAdapter la) {
        pieces.remove(la);
      }
    

    remove() takes an object and will do all of the necessary testing & removal for you, if that object is contained in the pieces list. You could make this return a bool or something for your own purposes, but I had no such need.

    Then just call something like:

    int view_to_remove = *AN_INT*
    adapter.removeAdapter(listAdapter.getAdapter(view_to_remove));
    adapter.notifyDataSetChanged();
    

提交回复
热议问题