实现Check on Custom对话框android

时间:2012-05-31 09:43:16

标签: android

我想在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();
    }

1 个答案:

答案 0 :(得分:0)

使用et1.getText().toString().equals("")代替et1.getText().equals(""),您的检查将有效。