Сбой при раздувании вложенного FragmentContainerView.Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Сбой при раздувании вложенного FragmentContainerView.

Сообщение Anonymous »

Вот структура того, чего я пытаюсь достичь:

Код: Выделить всё

Activity -opens-> BottomSheetDialogFragment -inflates-> CustomView -inflates-> FragmentContainerView -inflates-> Fragment -inflates-> a few views
При запуске я получаю следующий сбой (подробности не указаны):

Код: Выделить всё

java.lang.RuntimeException: Unable to resume activity {com.example.nestedfragments/com.example.nestedfragments.MainActivity}: android.view.InflateException: Binary XML file line #10 in com.example.nestedfragments:layout/fragment_main_dialog: Binary XML file line #10 in com.example.nestedfragments:layout/fragment_main_dialog: Error inflating class com.example.nestedfragments.ContainerView
Caused by: android.view.InflateException: Binary XML file line #10 in com.example.nestedfragments:layout/fragment_main_dialog: Binary XML file line #10 in com.example.nestedfragments:layout/fragment_main_dialog: Error inflating class com.example.nestedfragments.ContainerView
Caused by: android.view.InflateException: Binary XML file line #10 in com.example.nestedfragments:layout/fragment_main_dialog: Error inflating class com.example.nestedfragments.ContainerView
Caused by: java.lang.reflect.InvocationTargetException
Caused by: android.view.InflateException: Binary XML file line #13 in com.example.nestedfragments:layout/view_container: Binary XML file line #13 in com.example.nestedfragments:layout/view_container: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #13 in com.example.nestedfragments:layout/view_container: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: java.lang.IllegalStateException: FragmentManager is already executing transactions

Код: Выделить всё

MainActivity
использует supportFragmentManager для открытия MainDialogFragment
MainDialogFragment

Код: Выделить всё

class MainDialogFragment : BottomSheetDialogFragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return FragmentMainDialogBinding.inflate(inflater, container, false).root
}
}
ContainerView

Код: Выделить всё

class ContainerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {

private val binding = ViewContainerBinding.inflate(LayoutInflater.from(context), this)
}
NestedFragment

Код: Выделить всё

class NestedFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return FragmentNestedBinding.inflate(inflater, container, false).root
}
}
Я использую фрагмент AndroidX 1.7.0-rc02

Подробнее здесь: https://stackoverflow.com/questions/784 ... tainerview
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»