collapse recyclerview with different view types - android

So, I have a recyclerview with multiple view types. I'm using this link to generate my adapter class, becauseI have multiple viewholders in my recyclerview. Now the problem I have is with collapsing certain items inside it. What I want is whenever I press
the green toggle, item 2 and 3 in the list should collpase but 4,5,6 should remain upon,unless you have clicked on the green item ofcourse. I tried many ways to approach this but I can not achieve this with the link provided. Is there any way I can achieve this?

When you click collapsing button you have to remove your collapsing data from your all source list. When you remove your item from your list recyclerView automatically animates it.After that when you want to show it again you have to insert it your list again and notify that.RecyclerView also animates again when you insert it. There is a useful link here for inserting and removing special data from recyclerView https://medium.com/#suragch/updating-data-in-an-android-recyclerview-842e56adbfd8

Related

Show recycler view on a page by page basis

Im trying to achieve this recyclerview layout with arrow button that will trigger scrolling item
then, I have 2 choice to manipulate the view
Split the list inside adapter
Split the list inside viewmodel and bind it into adapter separately.
What should I choose between 2 of them. Or if you guys have any better idea please comments :)

Android. RecyclerView with collapsing items

I need to create recyclerView with collapsing items. For example, I have a list of 10 items. By default, I only need to flip the first 2 elements. But by clicking on the "See all" button, I need to display all the items in the list. And vice versa, by clicking on the "Hide" button, you need to leave only the first two items in the list. Here is an example:
I suppose to implement it like this: create a flag that determines whether the full list is displayed or not, and by clicking on the button, depending on the flag, send the full list to the adapter or cut it to two elements and call notifyDataSetChanged().
But this solution seemed to me not very good, perhaps there is a more elegant solution.
Note: I don't need nested collapsing elements. I just need to display two items from a list or all items.
Please help me.

Expanded and Collapse CardView not working fine

In RecyclerView, there is a problem about the adpter which assigns to every single item the ID. I use a button for every item (are CardView), and this button seems not to have a unique ID, because when I select it, it makes me expand the 1° and 13° item. I also need the expansion of the single cardview I check actually, I've notice that it expands the other cards through the list.
Why? How I can fix it?

Inner List in Android

I have a problem with lists.
I want to implement a scrollable big list, each element of which contains a text on the left side and a NON-scrollable inner list on the right side. (for example: the name of the flat and the list of its inhabitants names)
Both lists should be filled from the cursors and contain an informatio about them: I want to have an oppurtunitz to get all cursos fields when I click an element of the inner list.
As far as I understood I's not possible to solve it with two ListViews. ExpandableListView does not pass me because I do not want to expand the first list, I want to have the inner list always visible.
Do you have any ideas how can I realize it?
Try using a ListView for your big list, and an empty LinearLayout in each item. You fill the LinearLayout of each item programmatically in the big list adapters getView(..) method, where int position is the item number.
See also: android nested listview
Edit: Or use an ExpandableListView, which items you expand programmatically without animation with expandGroup(int position, boolean animate). Prevent collapsing by setting an ExpandableListView.OnGroupCollapseListener, in which you expand the group again. (seems a bit hacky)
Dokumentation: https://developer.android.com/reference/android/widget/ExpandableListView.html

How to display "More" list item in ListView?

I want to display a list item that says "More" at the end of my ListView. Clicking on this list-item will perform some action. How can I create this "more" list item?
I don't know about the "Clicking on this list-item will perform some action" part. The typical pattern is that once the user scrolls to the bottom, new material is loaded automatically. Some people do that by detecting the scroll. I do it by putting in a "More" placeholder and detecting when that is used. Here is a component that implements this pattern.
Just add another value to your arrayadapter (or any other adapter), you might be using.set the text to 'more' .
Suppose you have n items in the list then handle the (n+1)th postion click and do your stuff.
You can add a footer to your listview...
Did you check this post out?
Android ListView Footer View not being placed on the bottom of the screen

Categories

Resources