2012-05-31 26 views
0

我想在自定義對話框上執行檢查在Android上意味着我有「確定」和「取消」按鈕上的自定義對話框現在我有3個編輯文本上的自定義對話,當我點擊確定該對話框即消失無自動檢查在編輯文本在自定義對話框中執行檢查android

代碼如下:

 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(); 
    } 
+0

你的意思是「沒有檢入編輯文本」? –

+0

這裏是如何創建一個自定義對話框http://stackoverflow.com/questions/10443982/android-how-to-create-custom-dialog-alert/10444373#10444373 – Akram

回答

0

使用et1.getText().toString().equals(""),而不是et1.getText().equals("")和你的支票會工作。

+0

@saurabh trivedi讓我知道它是否工作您。 –