无法实例化以下类:- ;androidx.recyclerview.widget.recyclerview
我目前正在android studio中开发一个需要使用recyclerview的应用程序。编写代码后,该应用程序似乎没有显示任何错误,除了我的XML设计选项卡在问题部分发出以下输出——“无法实例化以下类”:无法实例化以下类:- ;androidx.recyclerview.widget.recyclerview,android,android-studio,android-recyclerview,android-xml,androidx,Android,Android Studio,Android Recyclerview,Android Xml,Androidx,我目前正在android studio中开发一个需要使用recyclerview的应用程序。编写代码后,该应用程序似乎没有显示任何错误,除了我的XML设计选项卡在问题部分发出以下输出——“无法实例化以下类”: androidx.recyclerview.widget.recyclerview 我已经尝试在这个网站上寻找解决方案,但没有找到任何类似的问题 这是我用于recyclerview的代码: 尝试将您的xml更改为: <?xml version="1.0" en
androidx.recyclerview.widget.recyclerview
我已经尝试在这个网站上寻找解决方案,但没有找到任何类似的问题
这是我用于recyclerview的代码:
尝试将您的xml更改为:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
我不确定是否有可能将recyclerview作为片段的根。添加com.google.android.material:material:1.2.1 dependency.it仍然没有修复是的,默认情况下它就在那里。理论上,这就是让它工作所需的全部。不需要更多的实现。你能展示你的完整布局以及如何设置它吗?当然,我已经发布了截图,请检查一下out@Chinez如何使用
fragment\u task\u list.xml
?您在哪里包含或放大它?我仍然得到相同的结果,但谢谢,是的,我将android.view.LayoutInflater添加到主java文件中
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>