【发布时间】:2021-05-31 15:30:03
【问题描述】:
【问题讨论】:
-
查看
MaterialAlertDialogBuilder -
@BenP。谢谢,我检查了,这解决了我的问题!
-
@ADM 我按照上面 Ben 的建议使用了
MaterialAlertDialogBuilder
标签: android dialog android-alertdialog
【问题讨论】:
MaterialAlertDialogBuilder
MaterialAlertDialogBuilder
标签: android dialog android-alertdialog
嗯,基本步骤是:
那里有大量的教程,即使在 SOF 中也是如此。请先搜索一下。
https://suragch.medium.com/creating-a-custom-alertdialog-bae919d2efa5 https://www.journaldev.com/22153/android-custom-alert-dialog
【讨论】:
首先,为对话框创建你的layout.xml,然后为示例代码调用你的对话框就像
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialog);
View view = LayoutInflater.from(context).inflate(R.layout.yourlayout, null);
builder.setView(view);
final androidx.appcompat.app.AlertDialog alertDialog = builder.create();
if (alertDialog.getWindow() != null) {
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
}
alertDialog.setCancelable(true);
alertDialog.show();
如果你想在 layout.xml
中声明你的视图TextView txexample = view.findViewById(R.id.txexample);
【讨论】: