3

从我的 BottomSheetDialogFragment 显示/关闭警报对话框时,屏幕上会闪烁,如何避免这种情况?提前致谢。

AlertDialog alertDialog = AlertDialog.Builder(activity)
.setMessage(messageStringId)
.setPositiveButton(positiveButtonTextId) { _, _, _ ->
//Action
}
.setNegativeButton(negativeButtonTextId) { _, _, _ ->
//Action
}
.create()

alertDialog.show()

问题:https ://youtu.be/yR8XXgHchmA

4

1 回答 1

0

我想您添加底页的方式有问题。我正在使用 BottomSheetDialogFragment 并且我没有看到任何闪烁。这是我的代码

class ItemListDialogFragment : BottomSheetDialogFragment() {
override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    return inflater.inflate(R.layout.fragment_item_list_dialog, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    show_dialog.setOnClickListener {
        AlertDialog.Builder(context!!)
            .setMessage("message")
            .setPositiveButton("ok", null)
            .setNegativeButton("cancel", null)
            .show()
    }
}
}
于 2019-12-06T07:12:42.000 回答