小编khu*_*hbu的帖子

在BottomSheetDialogFragment内部添加/替换片段

此代码:在其中我要添加片段的地方打开bottomSheetDialogFragment。

我想在bottomsheetDialogFragment中添加多个片段,但是会抛出

java.lang.IllegalArgumentException:找不到ID为0x7f0a01cb的视图

class AddNotesBottomSheetDialog : BottomSheetDialogFragment() {

private lateinit var bottomSheetDialog: BottomSheetDialog
private lateinit var bottomSheetBehavior: BottomSheetBehavior<View>

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
    Log.v(LOG_TAG, "-> onCreateDialog")

    bottomSheetDialog = BottomSheetDialog(context!!)

    var view = View.inflate(context, R.layout.bottom_sheet_notes, null)
    bindViews(view)
    bottomSheetDialog.setContentView(view)
    bottomSheetBehavior = BottomSheetBehavior.from(view.parent as View)
    bottomSheetBehavior.isHideable = false
    bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED

    return bottomSheetDialog
}

private fun bindViews(view: View) {
    loadAddNotesFragments()

}

override fun onStart() {
    super.onStart()
    Log.v(LOG_TAG, "-> onStart")

    bottomSheetBehavior.isHideable = false
    bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
    if (!visible)
        dialog.hide()
}


fun show(fragmentManager: FragmentManager) …
Run Code Online (Sandbox Code Playgroud)

android android-xml bottom-sheet

4
推荐指数
1
解决办法
1877
查看次数

标签 统计

android ×1

android-xml ×1

bottom-sheet ×1