我有一个显示的方法,AlertDialog
它有 3 Buttons
;中性、消极和积极。
我希望中立者在我的应用程序前面打开联系人应用程序,并带有Dialog
. 但是,即使它应该是“中立的”并且我没有发表任何声明,Dialog
当我回到我的时候它也关闭了。Activity
return
这是我的代码:
public static void showAddFriendDialog(Context ctx1) {
final Context ctx = ctx1;
//showGetFriendsFromContacts(ctx);
// Set an EditText view to get user input
final EditText input = new EditText(ctx); input.setHint("name");
final EditText input2 = new EditText(ctx); input2.setHint("firstname");
final EditText input3 = new EditText(ctx); input3.setHint("login/email");
// on est obligé de mettre un layout car on peut que mettre un setview
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(input);
layout.addView(input2);
layout.addView(input3);
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.setCancelable(true);
builder.setTitle("Add a friend");
builder.setMessage("Fill in the fields you know or get your contact info from your Contact List :");
builder.setView(layout);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
........................
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
builder.setNeutralButton("Contact List",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
ctx.startActivity(new Intent(null, ContactsContract.Contacts.CONTENT_URI));
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
return;
}
});
builder.show();
}
有人知道是什么原因造成的吗?