我想在 android 上实现对自定义对话框的检查意味着我在自定义对话框上有“确定”和“取消”按钮现在我在自定义对话框上有 3 个编辑文本,当我点击确定时对话框会自动消失而无需签入编辑文本
代码如下:
void openCustomDialog(){
AlertDialog.Builder customDialog
= new AlertDialog.Builder(orderDetails.this);
customDialog.setTitle("Custom Dialog");
LayoutInflater layoutInflater
= (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.mylayout,null);
et1 = (EditText)view.findViewById(R.id.et1);
et2 = (EditText)view.findViewById(R.id.et2);
et3 = (EditText)view.findViewById(R.id.et3);
customDialog.setPositiveButton("OK", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
System.out.println("######################3buton======="+et1.getText());
System.out.println("@@@@@@@@@##############3buton======="+et2.getText());
System.out.println("$$$$######3buton======="+et3.getText());
if(et1.getText().equals("")){
}
else{
}
}});
customDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
}});
customDialog.setView(view);
customDialog.show();
}