开发者

Remove view from MergeAdapter

开发者 https://www.devze.com 2023-03-26 00:04 出处:网络
Is it possible to remov开发者_开发问答e view or adapter from MergeAdapter somehow? I\'d try to extend it and remove the view from pieces but it\'s private. Or maybe there\'s an alternative solution to

Is it possible to remov开发者_开发问答e view or adapter from MergeAdapter somehow? I'd try to extend it and remove the view from pieces but it's private. Or maybe there's an alternative solution to show/hide view in this adapter? I tried to set its layout_height to zero and visibility to View.GONE, but it still shows the empty list item. Thanks in advance.


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


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! :-)


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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号