求助! 我是第一次使用 RecyclerView,在渲染过程中遇到问题, 我没有做任何 java 代码,因为我得到了这个错误,
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
这是我的 xml 代码:
<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>
我该如何解决这个问题?我在互联网上搜索但找不到正确的解决方案...
最佳答案
View.isInEditMode() 用于跳过在我们创建的自定义 View 的预览模式下不可执行的代码。您可能正在使用旧版本的 RecyclerView 库,它在 Android 的设计模式下没有预览。
尝试更新您的 recyclerview 库,问题将得到解决。这是目前在您的 gradle.build 文件中替换它的当前版本。
compile 'com.android.support:recyclerview-v7:22.2.1'
关于Android RecyclerView 在 XML 布局中呈现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32109244/