AlertDialog.Builder.setView вызывает StackOverflowError - PullRequest
0 голосов
/ 03 января 2019

Я пытаюсь показать диалог с пользовательским видом, но я сталкиваюсь с java.lang.StackOverflowError: stack size 8MB, и я не знаю, как с этим справиться.Вот мой кодЛюбая помощь приветствуется.

DialogFragment:

class MyDialogFragment : DialogFragment() {

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        return activity?.let {
            AlertDialog.Builder(it)
                .setView(layoutInflater.inflate(R.layout.custom_dialog, null))
                .create()
            }
    } ?: throw IllegalStateException("Activity cannot be null")
}

custom_dialog.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
...