android-recyclerview

RecyclerView SnapHelper fails to show first/last items

流过昼夜 提交于 2019-12-21 05:41:18
问题 I have a RecyclerView which is attached to a LinearSnapHelper to snap to center item. When I scroll to the first or last items, these items are not fully visible anymore. This problem is shown in the following image. How to solve it? 回答1: This issue happens when center of item which is next to the first/last is closer to the center of container. So, we should make some changes on snapping functionality to ignore this case. Since we need some fields in LinearSnapHelper class, we can copy its

Recyclerview changing items when is scrolled

拥有回忆 提交于 2019-12-21 05:40:46
问题 Can someone explain to me, what the problem is? When I scroll down and then back to the top, my items were changed for other items in the list, and if I scroll again, the items again are changed. This is my Adapter. public class AcademicAdapter extends RecyclerView.Adapter<AcademicAdapter.AcademicVH> { private LayoutInflater inflater; private List<AcademicStatus> data; public AcademicAdapter(List<AcademicStatus> data) { this.data = data; } @Override public AcademicVH onCreateViewHolder

How to retain the scrolled position of a Recycler view on back press from another activity?

自作多情 提交于 2019-12-21 05:33:05
问题 I saw many related questions about this topic, but none of them helped me. I am using a StaggeredGridLayout for my RecyclerView (showing cards ). Every CardView opens a new activity, the problem I am facing is that on back press from that new activity, the RecyclerView scrolls back to the top. I want it to retain the previously scrolled position. This what I use for now to set the layout : rv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); rv

Horiziontal recyclerview on DrawerLayout

落花浮王杯 提交于 2019-12-21 05:29:47
问题 This is my NavigationView 's layout <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/header" app:menu="@menu/meny" /> headerLayout has a horizontal RecyclerView which has some items that user can scroll on it. My problem is whenever I want to scroll in RecyclerView , drawerLayout is going to close . Is there any way to support horizontal

Animate RecyclerView items one by one

橙三吉。 提交于 2019-12-21 05:14:19
问题 I'm trying to animate my RecyclerView items in my app. I tried using this code in my adapter: public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { myHolder = holder as MyView; if (position > mCurrentPosition) { int currentAnim = Android.Resource.Animation.SlideInLeft; SetAnimation(holder.ItemView, currentAnim); mCurrentPosition = position; } } private void SetAnimation(View view, int currentAnim) { Animation anim = AnimationUtils.LoadAnimation(mContext,

How to use RecyclerView.Adapter notifyItemInserted/Removed in a right way?

大兔子大兔子 提交于 2019-12-21 05:06:11
问题 For instance, you have an adapter and in onBindViewHolder method you set OnClickListener to some views (and do some actions there depending on view position). You should assign final to position param of method onBindViewHolder so it could be accessible from onClick(). After changing dataset (remove or add item in list) you call onItemInserted or onItemRemoved and this really adds/removes a view in the recyclerview, BUT it does not refresh other viewitems so when you click on a neighbor

Android - Custom dynamically-generated compound View recreated in RecyclerView, causing poor performance

自作多情 提交于 2019-12-21 04:58:33
问题 I'm using a custom CompoundView which extends LinearLayout to display items of a RecyclerView . Each item displays an article which contains multiple paragraphs and images. The CompoundView adds TextView or ImageView dynamically based on the data attached by CompoundView.setData(List<DataPiece> pieces) , the number of which is unknown before data is attached. Each DataPiece object tells CompoundView whether it's a piece of text or an image. And here is the code for CompoundView.setData(List

Remove row from RecyclerView

亡梦爱人 提交于 2019-12-21 04:42:31
问题 I have somehow implemented recycle view with the help of this post, now my requirement is to remove a row at runtime from this Recycle View. link - http://treyrobinson.net/blog/android-l-tutorials-part-3-recyclerview-and-cardview/ Please help me. Thanks. 回答1: Since we don't know how is your adaper and given the info in that link you can create a method in the adapter that removes an object: public void removeItem(int position) { mData.remove(position); notifyItemRemoved(position); } You can

RecyclerView scroll dosen't work with NestedScrollView

天大地大妈咪最大 提交于 2019-12-21 04:42:09
问题 I have a layout where I have a NestedScrollView containing an Image, multiple buttons and a RecycleView. When I say recycleView.smoothScrollToPosition or recycleView.scrollToPosition() it doesn't do anything at the moment. Refuse to scroll even a pixel. If I remove the NestedScrollView it works fine, but in case I lose the scrolling effect on the surrounding areas. Does any of you met with this problem before? <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget

RecyclerView not displaying

北慕城南 提交于 2019-12-21 04:11:20
问题 I have a RecyclerView that's not displaying any items. Initially it's empty, but later I add items and call notifyDatasetChanged(). getItemCount() gets called and returns 25, onBindViewHolder gets called 3 times and sets up the view correctly. public AlbumListAdapter(FacebookActivity activity, long pageId, OnItemClickListener listener){ this.listener = listener; this.inflater = LayoutInflater.from(activity); this.service = new PagedGraphService<Album>(String.format("https://graph.facebook.com