android-recyclerview

Recycler view scroll to specific position

▼魔方 西西 提交于 2019-12-22 07:23:08
问题 I have custom recyclerview with view Holder. I have one searchview. I want to move recycler view position as per searchview searched text. How can I achieve this task? so that search text filter will perform and according to filteration I will get position of filtered text. and using that I can move my focus (scroll) to that position. Thank you 回答1: Try this: myRecyclerview.scrollToPosition(position); if not works in some cases(Keyboard opening etc.), try using delay. new Handler()

Why to use static with RecyclerView.ViewHolder [duplicate]

巧了我就是萌 提交于 2019-12-22 07:01:41
问题 This question already has answers here : What difference between static and non static viewholder in RecyclerView Adapter? (3 answers) Closed 4 years ago . Why is recommended to use static for a class extended from RecyclerView.ViewHolder if I create a new instance of this class on the onCreateViewHolder method and I guess that instance is used for each item: @Override public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent

LinearSnapHelper doesn't snap on edge items of RecyclerView

限于喜欢 提交于 2019-12-22 05:40:41
问题 This is a follow-up to my previous question. In my app I'm trying to have an horizontal RecyclerView that automatically snaps to the center item. To do so, I've attached a LinearSnapHelper to it. I've also created an item decoration that adds some left/right padding to the first/last element: public class OffsetItemDecoration extends RecyclerView.ItemDecoration { private Context ctx; public OffsetItemDecoration(Context ctx){ this.ctx = ctx; } @Override public void getItemOffsets(Rect outRect,

LinearSnapHelper doesn't snap on edge items of RecyclerView

懵懂的女人 提交于 2019-12-22 05:40:06
问题 This is a follow-up to my previous question. In my app I'm trying to have an horizontal RecyclerView that automatically snaps to the center item. To do so, I've attached a LinearSnapHelper to it. I've also created an item decoration that adds some left/right padding to the first/last element: public class OffsetItemDecoration extends RecyclerView.ItemDecoration { private Context ctx; public OffsetItemDecoration(Context ctx){ this.ctx = ctx; } @Override public void getItemOffsets(Rect outRect,

How to inflate Hashmap<String,List<Items>> into the Recyclerview

吃可爱长大的小学妹 提交于 2019-12-22 04:35:30
问题 I want that the string of keys must act as header and the list must be inflated under that map key in the RecyclerView . thanks for any help public class Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{ private WeakHashMap<String, List<VideoItem>> mData = new WeakHashMap<>(); private ArrayList<String> mKeys; ArrayList<WeakHashMap<String,List<VideoItem>>> hashMapArrayList; public Adapter(WeakHashMap<String, List<VideoItem>> mData, ArrayList<WeakHashMap<String,List<VideoItem>>>

RecyclerView refreshes items only when scrolling down and up

蹲街弑〆低调 提交于 2019-12-22 04:33:20
问题 I am making a simple recyclerview with Movie items. When I try adding new items they won't display in the recyclerview right away. For some reason I have to scroll down so the first item is gone, and then up again for the new item to be displayed (it's added at index 0). The adapter: public class MovieCardAdapter extends RecyclerView.Adapter<MovieCardAdapter.MovieViewHolder> { List<Movie> movieList; public MovieCardAdapter(final List<Movie> movieList) { this.movieList = movieList; } public

Android - How to add a dashed/dotted separator line for RecyclerView?

别来无恙 提交于 2019-12-22 04:32:18
问题 I have used the code from this answer to create a solid separator line for my RecyclerView s. However, I would like the line to be dashed/dotted. I already have a line_dashed.xml resource that I am using elsewhere in my app: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:color="@color/blue" android:dashGap="12dp" android:dashWidth="12dp" android:width="1dp" /> </shape> But if I try applying this as the drawable resource that is

Android - How to add a dashed/dotted separator line for RecyclerView?

邮差的信 提交于 2019-12-22 04:32:03
问题 I have used the code from this answer to create a solid separator line for my RecyclerView s. However, I would like the line to be dashed/dotted. I already have a line_dashed.xml resource that I am using elsewhere in my app: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:color="@color/blue" android:dashGap="12dp" android:dashWidth="12dp" android:width="1dp" /> </shape> But if I try applying this as the drawable resource that is

Trying to create a simple recyclerView in Kotlin, but the adapter is not applying properly

百般思念 提交于 2019-12-22 03:24:14
问题 I'm trying to create a simple recyclerView in Kotlin with data that I get via Volley (which I have confirmed returns the correct data), I keep running to the error E/RecyclerView: No adapter attached; skipping layout when in fact I have specified an adapter with the custom adapter class that I created: class ImageAdapter(var c: Context, var list: ArrayList<Image>) : RecyclerView.Adapter<ImageAdapter.ViewHolder>() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder?

Why RecyclerView.OnScrollListener is not an interface but an abstract class?

纵然是瞬间 提交于 2019-12-22 01:37:52
问题 To implement Endless Scroll pattern in to the RecyclerView I want to create a class like public class EndlessScrollAdapter<VH extends ViewHolder> extends RecyclerView.Adapter<VH> implements RecyclerView.OnScrollListener { } Because EndlessScrollAdapter should be responsible for both of the data and scroll event handling, this is the most convenient way to implement it. But, because in recyclerview-v7-21.0.3 , OnScrollListener declared like this /** * An OnScrollListener can be set on a