Reputation: 547
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);
}
Upvotes: 8
Views: 10579
Reputation: 1
Everything looks good, Try to make a Invalidate chache/restart. I that will work for you. There may be a chache problem.
Upvotes: 0
Reputation: 569
Add this line in your build.gradle file under dependencies block
implementation 'com.android.support:recyclerview-v7:25.1.0'
Upvotes: 0
Reputation: 5821
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 )
Upvotes: 7
Reputation: 763
Hi hope this will help you You have to remove scrollbars attribute from your view
Upvotes: -1
Reputation: 11
Just change Api level on the top of the screen in your xml viewer and make it 21 api level it will be work . hope it will help you.
Upvotes: 1
Reputation: 5338
This seems to be a bug in Android SDK 21. If you upgrade to SDK 22 the problem should disappear.
Upvotes: 3
Reputation: 1182
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
Upvotes: 1