Java RecyclerView android错误-尝试在android上运行应用程序时失败
我正在尝试创建一个显示所有用户联系人列表的应用程序,我正在使用RecyclerView。当我尝试运行我的应用程序失败时,我注意到问题出现在以下行中的“activity_main.xml”中:Java RecyclerView android错误-尝试在android上运行应用程序时失败,java,android,android-studio,Java,Android,Android Studio,我正在尝试创建一个显示所有用户联系人列表的应用程序,我正在使用RecyclerView。当我尝试运行我的应用程序失败时,我注意到问题出现在以下行中的“activity_main.xml”中: <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
不要忘记在xml中或在onCreate中以编程方式设置布局管理器:
app:layoutManager=“androidx.recyclerview.widget.LinearLayoutManager”
或
recyclerView.layoutManager=LinearLayoutManager(this)
问题出在xml文件中。需要更换
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
在这方面:
<androidx.recyclerview.widget.RecyclerView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/recycler_view"/>
在这行中,请提供一些日志、错误或更多代码。如果您是新手,我建议您在发布问题之前先浏览一下stackoverflow。请分享问题本身的错误。