0
我有一個形式,這個功能由用戶填寫,並在頂部的鏈接填寫表格時調用新的活動的網頁,如果利用試圖調用新的活動的用戶應該得到警告對話框,以「準備退出」。alertDialog確認退出上點擊新鏈接
我使用非擴展活動類將此功能由此產生的警報顯示,但disappering和呼叫下一個活動。
我有一個形式,這個功能由用戶填寫,並在頂部的鏈接填寫表格時調用新的活動的網頁,如果利用試圖調用新的活動的用戶應該得到警告對話框,以「準備退出」。alertDialog確認退出上點擊新鏈接
我使用非擴展活動類將此功能由此產生的警報顯示,但disappering和呼叫下一個活動。
下面是一個例子,可以幫助你
AlertDialog.Builder builder = new AlertDialog.Builder(ProfilesController.this);
builder.setMessage("Set message")
.setView(input)
.setPositiveButton("Enter", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
Button okButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
okButton.setOnClickListener(new CustomListener(alertDialog));
和自定義類會是這樣
public class CustomListener implements View.OnClickListener {
private final Dialog dialog;
public CustomListener(Dialog dialog) {
this.dialog = dialog;
}
public void onClick(View v) {
//do some thing here
}
}
可以顯示你的代碼? – moDev 2013-02-21 14:05:53