Abdul Hadi
Abdul Hadi

Reputation: 23

Android RecyclerView is giving exception in rendering in XML layout

Please help! I am using RecyclerView for first time and having problem during rendering, I haven't done any java code because I got this 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:463) Copy stack to clipboard

This is my xml code:

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="320dp"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:background="#FFF"
    android:scrollbars="vertical"></android.support.v7.widget.RecyclerView>

how do I solve this problem? I have searched on the internet but could not find right solution...

Upvotes: 1

Views: 2820

Answers (2)

Kirtan
Kirtan

Reputation: 1812

View.isInEditMode() is used to skip code which is not executable in preview mode of Custom View we create. It may happen you are using older version of RecyclerView library which had no preview in Design Mode of Android.

try to update your recyclerview library and problem will be solved.here is what current version as of now replace it in your gradle.build file.

compile 'com.android.support:recyclerview-v7:22.2.1'

Upvotes: 2

droidev
droidev

Reputation: 7390

2 suggestions :

  1. upgrade your sdk to 22
  2. set layout for recyclerview if you are not setting,

eg : recyclerView.setLayoutManager(new LinearLayoutManager(this));

in most of the case sdk version is the problem, so try updating your sdk first

Upvotes: 0

Related Questions