我想在警报对话框中添加两个编辑文本字段。就像解决方案听起来一样简单,我还没有能够收集到一个工作。我无法同时设置两个(编辑文本)视图。如何在AlertDialog框中添加两个编辑文本字段或视图?
如果您想查看任何进一步的代码,请留下您的意见。
alertDialog.setTitle("Values");
final EditText quantity = new EditText(SecondScan.this);
final EditText lot = new EditText(SecondScan.this);
quantity.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
lot.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
Project=arr[0].toString();
Item=arr[1].toString();
alertDialog.setMessage("Employee No. : " + (Login.user).trim()+
"\nWarehouse : " + (FirstScan.Warehouse).trim()+
"\nLocation : " + (FirstScan.Location).trim()+
"\nProject : " + Project.trim() +
"\nItem : " + Item.trim() +
"\nLot : " + Lot.trim()+
"\n\nQuantity :");
alertDialog.setView(quantity);
alertDialog.setView(lot);
// the bit of code that doesn't seem to be working.
alertDialog.setCancelable(false);
alertDialog.setPositiveButton("Update", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//ACTION
}
});
AlertDialog alert = alertDialog.create();
alert.show();
我想很多,第二个的量后,而只是其中的一种,似乎当我在这两种意见尽量推到被加工后发生的第一个编辑文本。
UPDATE:事实证明其实也有不单独添加多个视图一个警告对话框,而不必为它创建一个布局的方法。
两个视图创建布局,并设置作为AlertDialog内容 – Triode 2013-04-23 12:53:39
您可以通过创建一个对话框(不带alertDialog.Builder)并设置一个在xml中定义的内容视图吨。所以,你得到你自己的自定义布局的对话框。 – Opiatefuchs 2013-04-23 12:54:37
能否请您在答案中提供一些示例代码,以便我可以尝试并在他们解决问题时接受它们?谢谢。 – 2013-04-23 12:57:03