How to disable RecyclerView scrolling?

I cannot disable scrolling in the RecyclerView. I tried calling rv.setEnabled(false) but I can still scroll. How can I disable scrolling? 32 Answers 32 You should override the layoutManager of your recycleView for this. This way it will only disable scrolling, none of the other functionalities. You will still be able to handle click or … Read more

How to show an empty view with a RecyclerView?

I am used to put an special view inside the layout file as described in the ListActivity documentation to be displayed when there is no data. This view has the id “android:id/empty”. <TextView android:id=”@android:id/empty” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@string/no_data” /> I wonder how this can be done with the new RecyclerView? 15 Answers 15

Android Recyclerview GridLayoutManager column spacing

How do you set the column spacing with a RecyclerView using a GridLayoutManager? Setting the margin/padding inside my layout has no effect. 33 Answers 33 Following code works well, and each column has same width: public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration { private int spanCount; private int spacing; private boolean includeEdge; public GridSpacingItemDecoration(int spanCount, int spacing, … Read more

recyclerview No adapter attached; skipping layout

Just implemented RecyclerView in my code, replacing ListView. Everything works fine. The data is displayed. But error messages are being logged: 15:25:53.476 E/RecyclerView: No adapter attached; skipping layout 15:25:53.655 E/RecyclerView: No adapter attached; skipping layout for the following code: ArtistArrayAdapter adapter = new ArtistArrayAdapter(this, artists); recyclerView = (RecyclerView) findViewById(R.id.cardList); recyclerView.setHasFixedSize(true); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); As you … Read more

RecyclerView and java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder in Samsung devices

I have a recycler view that works perfectly on all devices except Samsung. On Samsung, I’m get java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder when I’m going back to the fragment with the recycler view from another activity. Adapter code: public class FeedRecyclerAdapter extends RecyclerView.Adapter<FeedRecyclerAdapter.MovieViewHolder> { public static final String getUserPhoto = APIConstants.BASE_URL + … Read more

RecyclerView inside ScrollView is not working

I’m trying to implement a layout which contains RecyclerView and ScrollView at the same layout. Layout template: <RelativeLayout> <ScrollView android:id=”@+id/myScrollView”> <unrelated data>…</unrealated data> <android.support.v7.widget.RecyclerView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:id=”@+id/my_recycler_view” /> </ScrollView> </RelativeLayout> Problems: i can scroll until the last element of ScrollView Things i tried: card view inside the ScrollView (now ScrollView contains RecyclerView) – can see … Read more

RecyclerView: Inconsistency detected. Invalid item position

Our QA has detected a bug: when rotating the Android device (Droid Turbo), the following RecyclerView-related crash happened: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 2(offset:2).state:3 To me, it looks like an internal error inside RecyclerView, as I can’t think of any way of this being caused directly by our code… Has anyone encountered this problem? … Read more