2014-04-12 37 views

回答

0

使用此代碼在任何你想顯示對話框..

AlertDialog.Builder builder =new AlertDialog.Builder(Dialogs.this); 
builder.setIcon(R.drawable.save1); 
builder.setTitle("Save Your Work"); 
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { 

@Override 
public void onClick(DialogInterface dialog, int which) { 
       // do something....... 
    } 
}); 
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 

@Override 
public void onClick(DialogInterface dialog, int which) { 
       // do something....... 
    } 
}); 
AlertDialog alert = builder.create(); 
alert.show(); 
+0

謝謝你這麼多........... :) –

+0

你可以下載圖像添加到對話框中.. – Mohit

+0

public void onClick(View v){ DB.open(); 光標c = DB.getContact(「1」);如果(c.moveToFirst()){0} { }則顯示(c); } while(c.moveToNext()); } DB.close(); String checkPass = pass.getText()。toString();如果(checkPass.equals(getpass)){startActivity(new Intent(Welcome.this,Main.class)); Toast.makeText(getBaseContext(),「Wrong PassWord」,Toast.LENGTH_LONG).show();其他{ } else { Toast.makeText } } –

0

您是在尋找簡單的AlertDialog或對話框?

例AlertDialog:

  AlertDialog.Builder alertDialog = new AlertDialog.Builder(Borc.this); 
       // Setting Dialog Title 
       alertDialog.setTitle("Eraser"); 
       // Setting Dialog Message 
       alertDialog.setMessage("Are you sure?"); 
       // Setting Icon to Dialog 
       alertDialog.setIcon(R.drawable.remove); 
       // Setting Positive "Yes" Button 
       alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
         dataBase.borclar.delete(String.valueOf(tableHelper.getSelectedRowId())); 
        } 
       }); 
       // Setting Negative "NO" Button 
       alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
        } 
       }); 
       // Showing Alert Message 
       alertDialog.show(); 
0

我想開始與Android對話的最好方式是閱讀文檔:Android Dialog Documentation。它們描述了各種類型的對話框以及如何在應用程序中實現它們。

如果您遇到特定問題,請告訴我們您的代碼並提出正確的問題。

相關問題