gpt4 book ai didi

安卓用户界面 : designing Alert dialog

转载 作者:太空宇宙 更新时间:2023-11-03 13:30:38 25 4
gpt4 key购买 nike

您好,我正在尝试设计如下所示的警报对话框 enter image description here

我做了如下基本设计:

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder.setTitle(R.string.share);
final EditText message = new EditText(context);
message.setGravity(Gravity.TOP);
message.setLines(10);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
(int) LayoutParams.MATCH_PARENT,
(int) LayoutParams.MATCH_PARENT);

请给我建议,我怎样才能通过警告对话框或其他方式实现这一点

最佳答案

是的,您可以像上面那样创建自定义警报对话框。您必须使用 Dialog 类。

你可以像这样使用 Dialog 类

// custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Title...");

// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Android custom dialog example!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);

Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});

dialog.show();

有关更多详细信息,请参阅此链接 Custom Dialog Box

关于安卓用户界面 : designing Alert dialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13758880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com