Remove View from MergeAdapter

Is there any way to remove the view or adapter from the MergeAdapter ? I will try to expand it and remove the view from pieces , but it is private . Or maybe there is an alternative solution to show / hide the view in this adapter? I tried setting its layout_height to zero and visibility on View.GONE , but it still shows an empty list item. Thanks in advance.

+4
source share
4 answers

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

setActive() in your mergeAdapter instance.

For example: To remove Textview (mytextView) from MergeAdapter (merAdapter), use:

 merAdapter.setActive(mytextViiew,false); 

And to turn it back on (to make it visible), use:

 merAdapter.setActive(mytextViiew,true); 

See the MergeAdapter documentation for more MergeAdapter :

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

+8
source

Is there any way to remove the view or adapter from the MergeAdapter?

Not now, sorry. It should not be added too complicated (remove it from the collection and call notifyDataSetChanged() to update the AdapterView ) if you want to take a picture. Contributions are welcome !:-)

+6
source

your MergeAdapter should have a method called getCount() .. if I understood you correctly, returning zero from there may solve your problem.

+1
source

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

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

remove() accepts the object and will do all the necessary testing and removal for you if this object is contained in the pieces list. You could make it return a bool or something for your own purposes, but I didn’t have such a need.

Then just call something like:

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

All Articles