Remove view from MergeAdapter

后端 未结 4 1581
再見小時候
再見小時候 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 10:46

    your MergeAdapter should be having method called getCount().. if i have understood you right, returning zero from there may solve your problem..

    0 讨论(0)
  • 2021-01-06 10:56

    To remove a view or an adapter from MergeAdapter use the following methods:

    setActive() on your mergeAdapter Instance.

    For Example : To remove a Textview (mytextView) from a MergeAdapter(merAdapter) use:

    merAdapter.setActive(mytextViiew,false);
    

    And to enable it again(to make it visible) use:

    merAdapter.setActive(mytextViiew,true);
    

    Refer the MergeAdapter documentation for details:

    https://github.com/commonsguy/cwac-merge

    0 讨论(0)
  • 2021-01-06 11:04

    Is it possible to remove view or adapter from MergeAdapter somehow?

    Not presently, sorry. It shouldn't be too hard to add (remove it from the collection and call notifyDataSetChanged() to update the AdapterView) if you wanted to take a shot at it. Contributions are welcome! :-)

    0 讨论(0)
  • 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();
    
    0 讨论(0)
提交回复
热议问题