【发布时间】:2014-11-09 16:57:59
【问题描述】:
今天我尝试使用新的 android RecyclerView。 我创建了一个带有空白活动的新项目,并将以下内容添加到其布局中:
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
在我添加的 gradle 构建依赖项中:
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:cardview-v7:21.+'
但 activity_main.xml 渲染仍然显示以下错误:
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
我自己似乎没有在网络上找到解决方案,因为每个人都说“在你的 gradle 构建中实现以下依赖项:...”我已经添加了。
谁能提供解决方案?
问候 tak3r07
编辑: 创建:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
【问题讨论】:
-
从 onCreate() 添加你的代码。您可能会在那里遗漏一些东西。
-
@mt0s 添加了 - 但我还没有更改任何内容,因为它是一个全新的项目。
-
请检查我的答案
标签: java android xml gradle android-recyclerview