android-recyclerview

In Android RecyclerView How to change the color of Alternate rows

感情迁移 提交于 2020-06-24 08:33:05
问题 I am new in android , recently I have learned recyclerview and i want to change the color of rows. Example: I have 10 rows and I want to change color like 5 rows blue and 5 rows red.Alternate rows color should be like this. From where I have to change this by Adapter or by MainActivity. Please help me 回答1: You can change the color of alternate row by adding the following code on your Adapter class. You can also change the images of your row by using this code. Put this code inside

ConstraintLayout together with RecyclerVIew (ListAdapter) appears to use HUGE amounts of memory (up to 1GB) when loading a list with +6000 items

时光毁灭记忆、已成空白 提交于 2020-06-23 12:17:22
问题 I'm building a simple FileExplorer for my app, and using Coroutines I get the files in a given path, and while displaying them, there are spikes in memory usage. I show the profiler tool tabs at the bottom of the post. My best guess is that the adapter is creating a viewholder for every single item on the list and that is using all the memory of the app and the device itself. Edit: by using RelativeLayout instead of ConstraintLayout, it decreased the memory usage by a factor of 3, and it

Horizontal RecyclerView follows first item height with wrap_content

扶醉桌前 提交于 2020-06-22 10:02:47
问题 I have a RecyclerView with a horizontal layout. The height of the individual adapter items can depend on the content of the item. So in theory it can look like the following: The problem I have now is that it wrap_content only seems to care about the height of the first problem, because the result I am getting looks like this: Where as you can see that the 4th item gets cut off. However, it works perfectly if I put the tallest item first. And to get rid of the obvious solution; I don't know

CardView background color always white

与世无争的帅哥 提交于 2020-06-22 05:01:27
问题 I am using RecyclerView with GridLayoutManager and I have each item as CardView. Unfortunately, the CardView here does not seem to change its background color. I tried in layout and programmatically as well but I have tried nothing seems to work. I Have been struggling for quite a while. I appreciate if someone could help me out with this issue. 回答1: If you want to change the card background color, use: app:cardBackgroundColor="@somecolor" like this: <android.support.v7.widget.CardView

CardView background color always white

限于喜欢 提交于 2020-06-22 05:01:05
问题 I am using RecyclerView with GridLayoutManager and I have each item as CardView. Unfortunately, the CardView here does not seem to change its background color. I tried in layout and programmatically as well but I have tried nothing seems to work. I Have been struggling for quite a while. I appreciate if someone could help me out with this issue. 回答1: If you want to change the card background color, use: app:cardBackgroundColor="@somecolor" like this: <android.support.v7.widget.CardView

android.widget.LinearLayout cannot be cast to androidx.recyclerview.widget.RecyclerView

一曲冷凌霜 提交于 2020-06-21 05:42:30
问题 Hi in the below code I am facing an issues android.widget.LinearLayout cannot be cast to androidx.recyclerview.widget.RecyclerView .I am implementing drag and drop the recyclerview list items .when I am dragging an item it is giving an error and drop or moving it is throwing an error. Can any one help me resolve this issue. public class DragListener implements View.OnDragListener { boolean isDropped = false; Listener mListener; public DragListener(Listener listener) { this.mListener =

Sort array result with date key in firebase database

[亡魂溺海] 提交于 2020-06-18 17:27:31
问题 I am fetching some records from firebase database in a RecyclerView. I am already fetching the data on the basis of a specific key-value. Now I want the data to be sorted for a date key whose format is MM-dd-yyyy. How can I sort it? My code to fetch it: FirebaseRecyclerAdapter<Eventsdata,Eventshistory.Game> adapter=new FirebaseRecyclerAdapter<Eventsdata,Eventshistory.Game>(Eventsdata.class ,R.layout.eventshistoryrow ,Eventshistory.Game.class ,reference.child("Events").orderByChild("uid")

Sort array result with date key in firebase database

大兔子大兔子 提交于 2020-06-18 17:26:22
问题 I am fetching some records from firebase database in a RecyclerView. I am already fetching the data on the basis of a specific key-value. Now I want the data to be sorted for a date key whose format is MM-dd-yyyy. How can I sort it? My code to fetch it: FirebaseRecyclerAdapter<Eventsdata,Eventshistory.Game> adapter=new FirebaseRecyclerAdapter<Eventsdata,Eventshistory.Game>(Eventsdata.class ,R.layout.eventshistoryrow ,Eventshistory.Game.class ,reference.child("Events").orderByChild("uid")

How to get a TEXT VIEW value from selected item in RECYCLERVIEW

旧城冷巷雨未停 提交于 2020-06-17 09:59:18
问题 I am trying to get a TextView value out of the selected item within the RecyclerView and send this value to an other activity . My RecyclerView layout file has two TextViews, one for the firstname and the lastname and the other one for the email . i found that recyclerview doesnt support some functionality like LIST VIEW , this is my code if any one can suggest for me something please. import android.content.Context; import android.content.Intent; import android.os.Handler; import android

How to auto play first video in recyclerview in ExoPlayer

做~自己de王妃 提交于 2020-06-17 09:43:30
问题 I have a problem in my code. I want to autoplay first video from recyclerview in ExoPlayer, The player is working good on scroll but the first video does not play automatically public class VideoPlayerRecyclerView extends RecyclerView { private static final String TAG = "VideoPlayerRecyclerView"; private enum VolumeState {ON, OFF}; // ui private ImageView thumbnail, volumeControl; private ProgressBar progressBar; private View viewHolderParent; private FrameLayout frameLayout; private