today I was trying to use the new android RecyclerView. I have created a new Project with a blank activity and added the following to its 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 gradle build dependencies I have 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 the activity_main.xml rendering 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
I don't seem to find a solution myself in the web since everyone says "implement the following dependencies in your gradle build: ..." which i have already added.
Can anyone provide a solution?
Regards Tak3r07
Edit: onCreate:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
I think that with RecyclerView you have at least to set the layout manager.
If you read the docs here :
In contrast to other adapter-backed views such as ListView or GridView, RecyclerView allows client code to provide custom layout arrangements for child views. These arrangements are controlled by the RecyclerView.LayoutManager. A LayoutManager must be provided for RecyclerView to function.
You can try after instantiating the RecyclerView to set the LayoutManager like that :
recyclerView.setLayoutManager(new LinearLayoutManager(this));
( later change it to a LayoutManager
that fits better your needs )
This seems to be a bug in Android SDK 21. If you upgrade to SDK 22 the problem should disappear.
I know the topic is a bit old, but the problem still persists and it's a known bug.
Anyhow the bug seems to be close to get a patch:
https://code.google.com/p/android/issues/detail?id=72117
Just upgrade to SDK 22 and the problem is fixed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With