android-recyclerview

Inserting RecyclerView items at zero position - always stay scrolled to top

早过忘川 提交于 2019-12-19 05:14:16
问题 I have a pretty standard RecyclerView with a vertical LinearLayoutManager . I keep inserting new items at the top and I'm calling notifyItemInserted(0) . I want the list to stay scrolled to the top ; to always display the 0th position. From my requirement's point of view, the LayoutManager behaves differently based on the number of items. While all items fit on the screen, it looks and behaves as I expect: The new item always appears on top and shifts everything below it. However, as soon as

Diffutil in recycleview, making it autoscroll if a new item is added

老子叫甜甜 提交于 2019-12-19 05:08:08
问题 If we use DiffUtil.Callback , and do adapter.setItems(itemList); diff.dispatchUpdatesTo(adapter); how can we make sure that adding of new elements will scroll to that new position. I have a case where I see item disappear, and a new one is created as a first element at the top, but not visible. It is hidden on top until you scroll down to make it visible. Before using DiffUtil , I was implementing this manually, and after I knew I was inserting at some position (on top) I could scroll to. 回答1

Populate recyclerview with a SQLite database?

时间秒杀一切 提交于 2019-12-19 04:56:55
问题 There's nothing wrong with the typical android cursor. But I'm still confused on how to implement it, does anyone here have an example or does anyone have another easier solution? My Recyclerview Adapter public class WatchlistAdapter extends RecyclerView.Adapter<WatchlistAdapter.MyViewHolder> { private LayoutInflater mInflater ; ArrayList<Games> data = new ArrayList<>(); //a way so it never equals null private int position; public WatchlistAdapter(Context context, ArrayList<Games> mData){

Android change recycler view column no. on pinch zoom

删除回忆录丶 提交于 2019-12-19 04:18:22
问题 I have in my layout recycler view for gallery application. I want to incorporate a pinch touch event listner such that the recycler view column no. increases or decreases on pich in and out. I have seen this type of interface in many gallery application. What is the best way to acheive this so that the transition is smooth. Small Video link :- http://sendvid.com/s68fiqpd I tried using below code (as provided by @Yogesh Rathi) but results is not what I want to achieve. import android.content

Toolbar leaving white space with hide on RecyclerView scroll

自作多情 提交于 2019-12-19 03:45:34
问题 I'm trying to hide my Toolbar on the RecyclerView scroll and so far it seems to have hidden, but it's leaving a white blank with it. I'm pretty sure this has something to do with the overlay of my MainActivity's layout and the fragment in the FrameLayout. Here is my activity_main.xml . I need the FrameLayout because I am loading different fragments with selection of an item in the Navigation Drawer. <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res

RecyclerView items clicking while scrolling

旧巷老猫 提交于 2019-12-19 02:52:19
问题 I have a RecyclerView . Inside its adapter's onBindViewHolder() I set the OnClickListener to the ViewHolder's root layout. However, I've recently noticed that I can't click on the RecyclerView 's items while it's being scrolled. Only after it's stopped. If I click somewhere on the RecyclerView while I'm scrolling it, the RecyclerView only stops at that position, no items are clicked. You can see what I mean inside the Gmail app. You can't open any email while you are scrolling its

Android RecyclerView Duplicate Item When Scrolling

狂风中的少年 提交于 2019-12-19 02:06:34
问题 I have a problem in RecyclerView . When I move item in RV and then scroll, saw some items has duplicated. 回答1: RecyclerView will recycle the view.When you delete data,call notifyItemChanged(pos) or notifyDataSetChanged() method. 回答2: I know its late but hope it will help someone. Override these two methods in your adapter. @Override public long getItemId(int position) { return position; } @Override public int getItemViewType(int position) { return position; } 回答3: It is your

How to use the MvvmCross fluent API to bind a RecyclerView item's TextView to a property of its ViewModel on Android?

匆匆过客 提交于 2019-12-19 02:01:28
问题 I am using MvvmCross in my Xamarin Android project. I have an MvxActivity with an MvxRecyclerView , that I have assigned an item template in its layout file. <MvxRecyclerView android:id="@+id/my_recycler_view" local:MvxItemTemplate="@layout/item_recycler_view" /> The ViewModel is quite simple, it consists just of one property that holds the data to display in the RecyclerView : public class MainViewModel : MvxViewModel { private IEnumerable<ViewModelItem> _viewModelItems; public IEnumerable

getAdapterPosition() not returning position of item in RecyclerView

和自甴很熟 提交于 2019-12-19 00:39:50
问题 This is a sort of follow-up or complement to this post. I am trying to get the position of an item in my RecyclerView, but none of the methods I have tried have worked. I called getAdapterPosition() in my PersonViewHolder constructor and assigned its value to the integer position, which is used in the UnitOneFragment class to do something accordingly (see onClick() method). But whatever that something is, it doesn't happen and my guess is because the getAdapterPosition() method doesn't work

Add Items to top of recyclerview

家住魔仙堡 提交于 2019-12-18 21:18:42
问题 I have a Recyclerview in my activity. when I pull down it will load new items to recycle view. Now I need to implement pull to refresh the concept to my recyclerview. I have done that. But when I call pull to refresh I am getting new items and added to recycle view bottom. I required to add new items to top of my recycle view. How can I add new loaded items to the top position of recycler view. public void refreshing() throws IllegalStateException{ new AsyncTask<String, Void, Void>() {