android-recyclerview

how to clear RecyclerView adapter data

耗尽温柔 提交于 2019-12-12 08:49:55
问题 Here in my UI, i have used two buttons to load different data to a RecyclerView. First time the data is displaying properly on click of each button. But if i click the button for the second time the data is adding to the adapter twice. I mean the the adapter is not cleared. it is keep on adding the data on click of button. I Think i have to do something with the adapter on click of a button. Can anyone pls let me know how to clear the adapter or where i am going wrong.. Here is the code.

Espresso Recyclerview scroll to end

冷暖自知 提交于 2019-12-12 08:33:57
问题 I have an Android application which has a RecyclerView with N elements, and when this RecyclerView reaches to end when scrolling, then more elements are added (so, it's an infinite list which loads data when scroll reached the bottom). I would like to test this, but I haven't found a way to do this. I use RecyclerViewActions which have scrollToPosition but even if I put the last position, the end is not reached (because the height of each element is high). Anybody know how could I do this?

How to scale up Recycler View center item while scrolling in android?

…衆ロ難τιáo~ 提交于 2019-12-12 08:15:43
问题 I need to always highlight the center item in the recycler view while scrolling by scaling up. 回答1: You should follow this code, this helped me to scale up the center item in recycler view. public class CenterZoomLayoutManager extends LinearLayoutManager { private final float mShrinkAmount = 0.15f; private final float mShrinkDistance = 0.9f; public CenterZoomLayoutManager(Context context) { super(context); } public CenterZoomLayoutManager(Context context, int orientation, boolean

RecyclerView with one static card and other dynamic cards

纵饮孤独 提交于 2019-12-12 08:00:50
问题 I need to do this: a RecycleView with CardView. The first card is static: it show "Details for this order". The other cards after the first are dynamics. So I decided to do this code: public class DocumentTypeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private List<DocumentType> document; //lista di card da riempire private Context context; public DocumentTypeAdapter(List<DocumentType>document, Context context) { this.document = document; this.context = context; } public

Adding multiple header in Recyclerview or Listview. randomly

冷暖自知 提交于 2019-12-12 07:56:50
问题 How can a add multiple header or dividers in RecyclerView or listview. randomly as highlighted in the image below: Multiple heading in RecyclerView on the basic of date - Demo Image 回答1: You can achieve it using the library SectionedRecyclerViewAdapter. It has the concept of "Sections" and each section can have its own header. It looks to me that you need to group your calls by "date". So you can create your Section class like this: class MySection extends StatelessSection { String date; List

Does Glide queue up every image request? Recyclerview loads are very slow when scrolling

假如想象 提交于 2019-12-12 07:54:55
问题 I have been seeing very long load times for images in our app using Glide 3.6 + a RecyclerView using a GridLayoutManager. The images are all around 20kb-40kb. It seems that glide queues up all the requests which causes the images to take quite awhile to load once you start scrolling further down the list. I've attached the logs from the GenericRequest class. V/GenericRequest﹕ finished setup for calling load in 0.170291 this: 249721749 V/GenericRequest﹕ finished onSizeReady in 0

use RecyclerView like vertical viewpager

ε祈祈猫儿з 提交于 2019-12-12 07:52:25
问题 is this possible to use recyclerview like verticalpager . what I want is when a user scrolls always the first item offset from the top be zero. like when you scroll in viewpager. is this possible? 回答1: Yes, you can. You can use a simple LinearLayoutManager: recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL)); and for RecyclerView.Adapter View item use layout_height="match_parent" to get View on full width of screen. or just use this lib:

Variable number of columns in GridLayoutManager

痞子三分冷 提交于 2019-12-12 07:47:17
问题 I wanted to display variable number of columns in a row of GridLayoutManager while using RecyclerView. The number of columns to be displayed depends on the size of the column's TextView. I don't know the column width as the text is being dynamically put in it. Can anyone help? StaggeredGridLayoutManager is not solving my purpose as it customizes the height but takes fixed number of columns. 回答1: Take a look at the setSpanSizeLookup method of the GridLayoutManager . It lets you specify the

How do I add a horizontal RecyclerView inside a list item

白昼怎懂夜的黑 提交于 2019-12-12 07:46:29
问题 The task of implementation is I need to create an infinite scrollable list which will scroll both horizontally and vertically. For this what I'm trying to do is that I have integrated a horizontal RecyclerView inside a vertical ListView item. Is this the right way to go about? I have tried other solutions but the scrolling has some issues. The problem is that when I try to implement the RecyclerView inside a list item the items do not get populated. public class HorizontalAdapter extends

If RecyclerView scrolls, then item id changes. How to resolve this?

瘦欲@ 提交于 2019-12-12 07:01:35
问题 This is my PDFListAdapter class method. I have downloaded file locally and save on Sqlite database. But if I scroll my RecyclerView , then I am having different item id. If not scroll RecyclerView then item id is perfect. The problem is when I scroll down the RecyclerView the item id changes. That is, I can fit one item on the screen at once. When I scroll to the second item, it saves different file and opens different. public class PDFListAdapter extends RecyclerView.Adapter<PDFListAdapter