我在这个类文件中构建了一个AlertDialog,对话框正常,但是当执行单击时,这些方法似乎没有调用。我究竟做错了什么?谢谢你的帮助!
//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...");
}
});
答案 0 :(得分:1)
你有什么期望呢?你现在没有那些街区的代码吗?
Android默认情况下不使用System.out.print();
- 使用日志:
Log.d(getClass().getName(),"Facebooking...");
答案 1 :(得分:0)
请尝试使用以下代码setNeutralButton
,setPositiveButton
,setNegativeButton
不适用于特定API。
//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.setButton1("Email",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.print("Emailing...");
}
});
builder.setButton2("Facebook",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.print("Facebooking...");
}
});
builder.setButton3("Twitter",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.print("Tweeting...");
}
});
希望它有所帮助...