Android. RecyclerView with collapsing items - android

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.

Related

collapse recyclerview with different view types

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

Recyclerview with X items and View more button

I would like to know if there is any way how to implement RecyclerView with only part of the collection. For example, the ArrayList would have 10 bitmaps in it, but only 6 can fit the screen without scrolling. So I want to show only 5 of them, and the 6th would be a clickable Button/ImageView which would say 'View 5 more'.
Is it possible to achieve this? Thanks.
one way would be having 2 lists in your adapter, one is the list that you actually show (show list) and the other one the full dataset. as long as you're not showing the full dataset, add a row at the end with the button show more, when clicking the button add a new batch of items from the full dataset to the show list.

Extended list view: Show text input inside once clicked

I am working on a UI where I have a list view. Each row has 2 information. One is Product name and the other is product ID stacked one over other. So each row has 2 lines of data.
What i want to do with this:
Once a user clicks on each row, it will further expand and show one input and one spinner. So it is basically for putting in Quantity and unit of measure.
Please let me know if this is achievable and if I can refer to some example.
What I need is more like
Taskos To Do List | Task List
https://play.google.com/store/apps/details?id=com.taskos&hl=en
All i need is that the category will not be expandable. Only the items will be expandable. All i need is an example of such app and then I can take it forward.
I think it could be done... you would need to put the extra widgets in your row layout, populate them and hide them upon list creation, then in your onListItemCLick you could unhide them.
Note I have no idea if this would work, but it seems reasonable that it might and it's what I would try and do to achieve the goal.
listView cannot be expanded. however you can use an expandablelistView
But the kind of functionality you want cannot be done this way(I guess.).
You can use
registerForContextMenu("your list View");
to register your list view
onCreateContextMenu
for the kind of action you want to be performed in your case its dialog with EditText and Spinner to have input from user

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

Creating a floating, editable and scrollable list in Android

I want to show a list of items when the user clicks an overlay item on a map. The user should be able to select any of these items and edit them. The list can have many items (more than that can fit in one active screen) therefore it needs to be scrollable.
You could do it with an activity with a transparent background, then launch that activity on top. From there you can make the list editable, by using a custom list adapter & updating the data contained within the adapter.

Categories

Resources