I'm building a couple of custom ListViews which contains listViewItems whom expands on click. I made my first one without major trouble, and the listViewItems expands correctly on click.
Now i'm building an other ListView, with the difference that it contains more than one kind of item, becuse of this i found it convenient to let the adaper contain a list of views instead of a list of data and creating the views when prompted for them by getView(XX).
Everything works fine except that the items in the new list does not expand until i swap activity back and forth to redraw. I have tested to mimic the implementation in the first listview (with several drawbacks) and with this gets them to redraw correctly.
The main diffrence is these 2 lines, the first one works the second one does not redraw.
return new TransactionChild(context, attrs, transactions.get(position));
return (View) children.get(position);
What is the best way to fix this? Try to force a redraw on the entire list(on expanding view shifts the rest down...)? or is there something neater i can do with either the ListView or the adapter?
Help would be great :D
preguntado el 23 de abril de 13 a las 13:04
You can use an ExpandableListView where the groups don't have any children and have different layouts on group open and closed.
If using a normal ListView, i suggest you make use of the getItemViewType() method of the Adapter, so in this way you keed a list of items normal and clicked and on getView you check the type and change the layout. And on the click listener you change the type of the item clicked and notify for data changed.