Android 如何在对话框中显示recyclerVIew?
我的XML如下-live\u test\u question\u change\u dialog\u layout.XMLAndroid 如何在对话框中显示recyclerVIew?,android,android-recyclerview,android-alertdialog,alert,Android,Android Recyclerview,Android Alertdialog,Alert,我的XML如下-live\u test\u question\u change\u dialog\u layout.XML <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/live_test_change_question_option_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/a"
android:background="@drawable/option_number_background"
android:textStyle="bold"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
/>
</RelativeLayout>
这个代码有什么问题?如何解决这个问题?我认为您使用的是
androidx
依赖关系
你应该使用
<androidx.recyclerview.widget.RecyclerView
您必须创建一个从DialogFragment扩展而来的新“片段”
public class MyDialogWithRecyclerView extends DialogFragment
官方文档很好,我使用它在DialogFragment中创建了Firestore RecyclerView。这对于一个普通的回收者来说是一样的
如果你曾经使用过RV和碎片,你应该很好,但你可以问我任何问题
编辑
抱歉,该版本已弃用,这是正确的文档
请显示xml。您好。问题中给出了XML。您是否在项目中使用了androidX
依赖项?签入build.gradle文件请提供主xmlIt在行中崩溃-dialog.setContentView(R.layout.live\u test\u question\u change\u dialog\u layout);2020年,人们仍在使用android.support.v7.widget.RecyclerView
。
<androidx.recyclerview.widget.RecyclerView
<android.support.v7.widget.RecyclerView
public class MyDialogWithRecyclerView extends DialogFragment