1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this);
        ad.setMessage("사용하실 닉네임을 입력해주세요.");
 
        // EditText 삽입하기
        final EditText et = new EditText(getApplicationContext());
        et.setText(AppInfo.NICK);
        FrameLayout container = new FrameLayout(MainActivity.this);
        FrameLayout.LayoutParams params = new  FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 50;
        params.rightMargin = 50;
        et.setLayoutParams(params);
        container.addView(et);
        ad.setView(container);
        //
 
        // 확인 버튼 설정
        ad.setPositiveButton("변경"new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String value = et.getText().toString();
                if (value.trim().equals("")) {
                    Toast.makeText(getApplicationContext(),"닉네임을 입력해주세요.", Toast.LENGTH_SHORT).show();
                    return;
                }
                //닉네임이 금지단어에 포함 되는지 체크
                String tmp[] = AppInfo.BLOCK_KEYWORD.split(",");
                for (String row: tmp) {
                    if (value.contains(row)) {
                        Toast.makeText(getApplicationContext(),"닉네임에 금지단어가 포함되어 있네요.", Toast.LENGTH_SHORT).show();
                        return;
                    }
                }
                //
                dialog.dismiss();
 
                changeNick(value);
            }
        });
 
        // 취소 버튼 설정
        ad.setNegativeButton("취소"new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        ad.show();
cs


+ Recent posts