gpt4 book ai didi

android - TextView 和编辑文本的警告对话框间距问题

转载 作者:太空宇宙 更新时间:2023-11-03 12:42:27 24 4
gpt4 key购买 nike

我无法在我的 AlertDialog 中看到“我的数据”,因为它与 EditText 重叠。

           Context context = MyActivity.this;
AlertDialog.Builder alert = new AlertDialog.Builder(context);

alert.setTitle(" NEW TITLE");
alert.setMessage("MESSAGE 1");

final TextView tx = new TextView(this);
tx.setText("MY DATA");
alert.setView(tx);

// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);


alert.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {

/* User clicked OK so do some stuff */
}
});

alert.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {

/* User clicked Cancel so do some stuff */
}
});

alert.create();
alert.show();

最佳答案

试试这个:

LinearLayout layout = new LinearLayout(this);
layout.setOrientation(Vertical);

final TextView tx = new TextView(this);
tx.setText("MY DATA");
layout.addView(tx);

// Set an EditText view to get user input
final EditText input = new EditText(this);
layout.addView(input);

alert.setView(layout);

关于android - TextView 和编辑文本的警告对话框间距问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5549372/

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