처음에는 가운데 버튼이 다른 AlertDialog
을 열어주는 세 개의 버튼이있는 AlertDialog
을 만듭니다. 버튼을 누른 후 두 번째 AlertDialog
이 닫히면 첫 번째 버튼이 닫히는 문제가 있습니다. 두 번째 버튼을 누르면 AlertDialogs
닫힌 것 같아요. AlertDialog
. 첫 번째 AlertDialog
가 자신의 단추가 다른 AlertDialog
을 열 수 있도록자바 안드로이드 - 두 개의 대화 상자, 첫 번째 대화 상자가 두 번째 종료 후 닫히는 것을 방지합니다.
는 내가 원하는이며, 두 번째 AlertDialog
이 버튼을 누를 때, 그것은 단지 그 자체를 닫고 다시 처음으로 돌아갑니다. 이것을 달성 할 수있는 방법이 있습니까? 여기
AlertDialog
여는 데 사용되는 버튼의 코드 : 중앙 버튼을 사용하여 다른
AlertDialog
를 여는 다른 버튼을 포함하는
AlertDialog
을 여는 버튼의 코드 여기
final ImageButton fabgroup = (ImageButton) findViewById(R.id.groupButton);
있어 (만들기 버튼) 두 번째 단추가 눌려지면 두 단추 모두 닫힙니다 (예 또는 아니오 단추, 두 번째 단추를 닫고 첫 번째 AlertDialog
으로 돌아가고 자 할 때 원하는 항목이 아님). 이론적으로는 꽤 혼란스러워서 필요한 경우 명확히하려고 노력할 수 있습니다) :
fabgroup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(CreateNote.this);
helpBuilder.setTitle("Select a group");
helpBuilder.setMessage("Add to group?");
final TextView input = new TextView(mainactiv.this);
input.setSingleLine();
input.setText("");
helpBuilder.setView(input);
helpBuilder.setNegativeButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Do nothing but close the dialog
Toast.makeText(CreateNote.this, "Page has been added to group", Toast.LENGTH_SHORT).show();
}
});
helpBuilder.setNeutralButton("Create", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//open another alertbox
AlertDialog.Builder helpBuilder2 = new AlertDialog.Builder(CreateNote.this);
helpBuilder2.setTitle("Assign a new group");
helpBuilder2.setMessage("Create group?");
final EditText input = new EditText(CreateNote.this);
input.setSingleLine();
input.setText("");
helpBuilder2.setView(input);
helpBuilder2.setNegativeButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Create Group
Toast.makeText(CreateNote.this, "Group has been created", Toast.LENGTH_SHORT).show();
}
});
helpBuilder2.setPositiveButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Remember, create doesn't show the dialog
AlertDialog helpDialog2 = helpBuilder2.create();
helpDialog2.show();
}
});
helpBuilder.setPositiveButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Remember, create doesn't show the dialog
AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
}
});
도움을 주시면 대단히 감사하겠습니다.
불행히도 대화 상자가 닫히지 않는다고 생각됩니다. –