Recyclerview with X items and View more button - android

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.

Related

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.

Scrolling Card List item by item

I'm going to create a card list like Google Play app that always show 3 items completely and one or two item part that tell us that the list has more items.
This is easy by RecyclerView that use LinearLayoutManager in HORIZONTAL mode. That explained in this answer.
But the problem is item by item scrolling like Google Play app that doesn't stop in any place and if you stop scrolling in middle of an item it moves to begin of that.
And it shows exactly 3 item in the main box not 2 and a half or 3 and a few.
There's a Library just for that case named GravitySnapHelper: https://github.com/rubensousa/GravitySnapHelper
You can use viewpager for this.

How to show listview items and limit them to have pages like?

I'm using Android Studio, and I have a listView that musts display an important amount of items. showing all of these items have a huge impact on performances. SO I would like to show them 10 by 10, and with a button show the 10 next items. After some researches, I found this android How to limit list items display in ListView and a button show more and this How to limit list items display in ListView by 10 and next 10after clicking next button. But these didn't lead me to a success. The 1st link looks easier but I didn't know where to put the code samples to make it work. Thanks for help !
You dont need to show "Load More" Button always. You can use Android's Recycler View for this. It will load only the data which can be shown on screen. Rest of the data will be loaded as you scroll down. And the view which is scrolled up (Vanishing views) are recycled automatically.
Check this links
https://developer.android.com/training/material/lists-cards.html
https://guides.codepath.com/android/using-the-recyclerview
https://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156
First link question have a simple answer, If you made a custom adapter for populating listview then there will be a getCount() method which will return the number of items you want to show on listview. if you have not getCount() method then simply override it.
Link
there i(variable) have that value which number if items you want to show on listview, on refresh button click increment the value of i(variable) that will again refresh the whole listview and add the total number of items in listview which is the value of i(variable)

Make a dropdown menu on ListView for only one row

EDIT
It's on swedish, but this is what i got with list view.
Every listview item has a empty Linearlayout that i add a view to when i press the down arrow button. the problem is that every fifth item gets this or i can only click on the first 5.
I dont get why they make ListView so complicated. i want to be able to get a child that is in the list without seening it!
The Problem
My way to add the view makes every fifth item to add the view when i only want one position to have this "Mängd" row.
Why Can i only edit listitems when they are visible on the screen.
The child will be static at 5 items even though i got like 20 item....
Is there any way to only say that item 1 will have this and not
position - firstvisibleposition
i think this is the problem with the listview
My code is not understandable at the time because of other things so i hope you get my problem anyways.
This is my main question
It seems like the thing i add to position 0 also happens to 6 and 12 Why is ListView this wierd ?

Android: How do I remove an item from a gridview, having the remaing items shuffle into place

BACKGROUND:
I have a grid of 36 buttons, lets say a 6 rows & 6 columns numbered 1 to 36, displayed 2 rows at a time via a GridView and custom Adapter
The grid displays fine, and all of the scrolling works properly.
QUESTION:
I want to be able to click on an item, have it removed from the grid and the remain items shuffle up into place. Currently I am able to disable the item disabled, set its visibility to INVISIBLE or GONE, but none of these will actually remove it from the display.
Suggestions?
Specifically, you need to remove the corresponding object from the data set of the underlying adapter and then call adapter.notifyDataSetChanged(). This isn't going to provide you with an animation, though, if that was part of this question.
It may be interesting to try a tween animation for the item in question and then finally remove it from your adapter at the end. I'm not well-versed in animation, so I'm not sure how well this will work in an AdapterView.
You should be able to update the adapter, and then call notifyDataSetChanged to force the grid view to be updated.

Categories

Resources