问题
I am creating 3 level expandable list with swipe functionality at 3rd level.
I am facing an issue with swiping feature at 3rd level swipelistview, when caching is used.
For swiping, I am using "47deg/android-swipelistview" https://github.com/47deg/android-swipelistview/ library. For creating 3 level expandable list, I used code from http://mylifewithandroid.blogspot.in/2011/02/3-level-expandable-lists.html. I used cache concept at 3 places: 1. 2nd level expandable list, 2. 3rd level swipelistview 3. swipelistview nodes. This way, it gave good performance while scrolling/expanding/collapsing the expandable list.
But at that time, swiping functionality stop working. If I stop using cache at swipelistview node level (inside getview() function of adapter of swipelistview), swiping feature works properly.
My question is, if I create new view everytime at getview() of swipelistview class or reuse convertedview, swiping feature continues to work. But if I create node first time only for every child and next time on the getview request, I sent already prepared node, why swiping feature stops working.
P.S. When I say, swiping feature stops working, GUI is not updated properly.
I have sample project available with me, in case anyone needs it. or if anyone requires specific portion of the code, I can also provide the same.
回答1:
I think your problem is like these questions and there is solution so Check these Link and link2
回答2:
In order to get it working, I implemented it with following approach. I am not sure, this is the best way or not.
We used
getViewTypeCount()
andgetItemViewType()
functions in listview base adapter to return different view type for each row. This way, it does not try to use same view while using ingetView()
facility.Similarly for
ExpandableListViewAdapter
, we usedgetChildTypeCount()
andgetChildType()
to return different type.
This way, I was able to achieve what I was looking for. I am sure, this is not the most optimize way as it does not allow, reusablity of components, but it works in my case, as my app does not need thousands of components in list.
来源:https://stackoverflow.com/questions/18857452/3-level-expandable-list-view-with-swipe-feature