Android RecyclerView Error

Today I tried to use the new android RecyclerView. I created a new project with empty activity and added it to the layout:

<android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent"/> 

In the gradle build dependencies, I added:

 compile 'com.android.support:support-v4:21.0.0' compile 'com.android.support:recyclerview-v7:21.+' compile 'com.android.support:cardview-v7:21.+' 

But rendering activity_main.xml still shows me the following error:

 Rendering Problems The following classes could not be instantiated: - android.support.v7.widget.RecyclerView (Open Class, Show Exception) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE Exception Details java.lang.UnsupportedOperationException: Unsupported Service: accessibility   at com.android.layoutlib.bridge.android.BridgeContext.getSystemService(BridgeContext.java:465 

It seems that I did not find a solution on the network, as everyone says: "Add the following dependencies to your gradle build: ...", which I already added.

Can someone provide a solution?

Relationship Tak3r07

Edit: onCreate:

 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } 
+8
java android xml gradle android-recyclerview
source share
6 answers

I think that with RecyclerView you have at least to install a layout manager.

If you read the docs here :

Unlike other views supported by the adapter, such as ListView or GridView, RecyclerView allows the client code to provide a custom layout for children. These mechanisms are controlled by RecyclerView.LayoutManager. A LayoutManager must be provided for the RecyclerView to work.

You can try after creating an instance of RecyclerView to install the LayoutManager as follows:

 recyclerView.setLayoutManager(new LinearLayoutManager(this)); 

(later change it to a LayoutManager that best suits your needs)

+6
source share

This seems to be a bug in Android SDK 21. If you upgrade to SDK 22, the problem should go away.

+2
source share

I know the topic is a bit outdated, but the problem still persists, and this is a known bug.

In any case, the error seems close to getting the patch:

https://code.google.com/p/android/issues/detail?id=72117

+1
source share

Just update SDK 22 and the problem is fixed.

+1
source share

Just change the Api level at the top of the screen in your xml viewer and do it at the 21 api level, it will work. Hope this helps you.

+1
source share

Hi, this will help you. You need to remove the scroll attribute from your view.

-one
source share

All Articles