I am trying to implement a 2-level expandable list view. I found the reference for the same from here : http://www.allappsdevelopers.com/TopicDetail.aspx?TopicID=c991d70a-4570-4e4b-8378-2191a4247a84
This works fine. But as soon as i scroll the list view or i click on another group, the expanded children get collapsed.
I would like to preserve the expanded groups.
Any help appreciated
When you scroll a ListView the views are recycled and hence if you want to keep your group expanded you will need to maintain a list of the clicked groups.
Related
I have a list of elements in a recycler view that are generated dynamically using data binding. Each element has a bottom view that is initially set to View.GONE, however once a user clicks the element and the view is expanded, the recycler view automatically scrolls back to the top of the list. Conversely, if the view is expanded and then clicked again to collapse, the recycler view scrolls to the top of the list again. I have tried keeping track of the ID's of the elements for the adapter (again using data binding), setting focus to the child element when they expand or collapse, and using binding adapters to animate the expand/collapse itself.
My suspicion is that the adapter in the recycler view is receiving a onNotifyDataChanged() alert when the height of one of the child changes, rendering an additional view (still inside one of the children though, not a separate child in the list), and automatically scrolls to the top. Is there a way to override this? Does anyone know what else might be causing the list to snap to the top when one of the elements is clicked -> expanded/collapsed?
So I found the solution to my issue in case someone encounters something similar. I actually ended up finding this answer: RecyclerView notifyDataSetChanged scrolls to top position
and the second solution involving the staggered layout manager was the route I went with, since I want to be able to wrap the content. My suspicions were correct that it had to do with the changing height of the elements in the recycler view. The expandable item's parent wrapped content, so the recycler view was forced to recalculate the size of the item once the expandable portion appeared/disappeared (at least that's what I got out of it).
I have a recycler view which has its items in a card view. The recycler view gets its data from a sql database within the app . Now I want to implement two features to this recycler view items. First , whenever the individual cards are tapped , I want them to enlarge and display more data and should shrink back when tapped again. It is not like the case of expandable list view where it expands into a child list view. I want the height of the card to increase and just show some more information and buttons. Second I want the items to swipe left . I know there is a feature for that in recycler view , but I want to customise the swipe feature. Swipe from right should be locked , and when swiped from left , It should not go off list completely. It should show two buttons and should go off list only when one of the buttons is clicked. I have been looking , but there is no proper explaination anywhere. Please guide me through this process.
For your first question, set the adapter layout_height to wrap_content and set the buttons visibility to GONE. Implement the OnClick listener in the RecyclerView adapter and set the visibility of the buttons to VISIBLE if GONE and GONE if VISIBLE or use a boolean to alternate the visibility.
For your second question, this might help:
https://www.learn2crack.com/2016/02/custom-swipe-recyclerview.html
How can I make my Android SwipeableCardViews more like the IOS 7 mail app (swipe to show buttons)
https://github.com/daimajia/AndroidSwipeLayout
I am using expandable list view for my app. Everything is working correctly, but I want an animation when a group is going to expand i.e all the childs should come with an animation when a group is clicked. Does any one of you have any luck in this regard?
I have a one custome view and on expandable list view.
list is scrolling fine but when i tried to place both in a scroll view its not working.
I decided to place the custom view in one of the element in the expandable list view.
But, each element in the list has two items Group and Childs.
How to replace both of them with my view at first position...?
Thanks in advance...!
Finally i got a solution for this.
Load your custom view into the ExpandableListView as Group with 0 children.
Then make group indicator invisible.. that's it. :)
I need to implement list view that must show selected item in the center of list view.
Is it possible?
The problem is that list view forbid scrolling before top item and after last item.
The only workaround here I found is to add several dummy header and bottom items and use setSelectionFromTop() method for right positioning.
Is there any other better way?
Thanks
You could use a circular ListView Check this thread on how to implement it
and use smoothScrollToPosition to bring your particular view to the center.
You shouldn't need to add multiple dummy list items. Just extend your Adapter and use a single blank dummy list item that you can programmatically adjust the size of based on the screen resolution of the device.