我目前有一個應該返回對話框結果的方法。我使用的代碼是通過對話框返回值
private int ShowDialog(String FileName)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
// set title
alertDialogBuilder.setTitle("Play File");
// set dialog message
alertDialogBuilder
.setMessage("Would you like .... file")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id)
{
dialog.cancel();
return 1;
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
return 0;
}
});
AlertDialog alert11 = alertDialogBuilder.create();
alert11.show();
}
但似乎onClick方法應該是一個void。無論如何,我可以使這個方法返回一個值,並作爲回報使ShowDialog方法返回該值。
「方法,它應該返回一個對話的結果」你能明確告訴你要返回 – 2013-02-20 05:21:52
你怎麼想回到什麼結果對話框的? – SKT 2013-02-20 05:33:50