[안드로이드 스튜디오] AlertDialog 생성 (간단한 팝업)
# App/Android(JAVA)

[안드로이드 스튜디오] AlertDialog 생성 (간단한 팝업)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
private void createUserName() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("채팅방에 사용할 이름을 입력하세요");
 
        final EditText builder_input = new EditText(getActivity());
 
        builder.setView(builder_input);
        builder.setPositiveButton("확인"new DialogInterface.OnClickListener() {
            @Override public void onClick(DialogInterface dialogInterface, int i) {
                name = builder_input.getText().toString();
            }
        });
 
        builder.setNegativeButton("취소"new DialogInterface.OnClickListener() {
            @Override public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
                // 취소를 누르면 이름을 입력할 때 까지 요청
                createUserName();
            }
        });
 
        builder.show();
    }
cs






728x90