Android RecyclerView 在 XML 布局中呈现异常
Android RecyclerView is giving exception in rendering in XML layout
请帮忙!
我是第一次使用 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>
我该如何解决这个问题?我已经在互联网上搜索但找不到合适的解决方案...
2 条建议:
- 将您的 SDK 升级到 22
- 设置recyclerview的布局,如果你没有设置,
例如:recyclerView.setLayoutManager(new LinearLayoutManager(this));
在大多数情况下,sdk 版本有问题,因此请先尝试更新您的 sdk
View.isInEditMode() 用于跳过在我们创建的自定义视图的预览模式下不可执行的代码。您可能正在使用旧版本的 RecyclerView 库,它在 Android.
的设计模式下没有预览
尝试更新您的 recyclerview 库,问题是 solved.here 是什么当前版本,现在在您的 gradle.build 文件中替换它。
compile 'com.android.support:recyclerview-v7:22.2.1'
请帮忙! 我是第一次使用 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>
我该如何解决这个问题?我已经在互联网上搜索但找不到合适的解决方案...
2 条建议:
- 将您的 SDK 升级到 22
- 设置recyclerview的布局,如果你没有设置,
例如:recyclerView.setLayoutManager(new LinearLayoutManager(this));
在大多数情况下,sdk 版本有问题,因此请先尝试更新您的 sdk
View.isInEditMode() 用于跳过在我们创建的自定义视图的预览模式下不可执行的代码。您可能正在使用旧版本的 RecyclerView 库,它在 Android.
的设计模式下没有预览尝试更新您的 recyclerview 库,问题是 solved.here 是什么当前版本,现在在您的 gradle.build 文件中替换它。
compile 'com.android.support:recyclerview-v7:22.2.1'