我在這個類文件中構建了一個AlertDialog,並且對話框很好,但是當執行單擊操作時,這些方法似乎不會被調用。我究竟做錯了什麼?謝謝你的幫助!Android對話框OnClick方法不起作用?
//AlertView Builder
final AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this);
builder.setTitle(" ");
builder.setIcon(R.drawable.banner);
builder.setMessage("Share this picture using any of the below!");
builder.setPositiveButton("Email",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.print("Emailing...");
}
});
builder.setNeutralButton("Facebook",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.print("Facebooking...");
}
});
builder.setNegativeButton("Twitter",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.print("Tweeting...");
}
});
告訴我,從你在哪裏調用此方法的代碼?並且在方法聲明的地方? – 2012-04-24 04:07:08
現在的方法只是system.out.println語句,但他們永遠不會執行 – rjfellman 2012-04-24 04:08:27
是的。嘗試使用JRaymond下面給出的陳述。 – 2012-04-24 04:11:02