- 체크 박스 일 경우 setMultiChoiceItems() 레디오 버튼일 경우 setSingleChoiceItems() 메소드를 이용해서 설정한다.
- 기본값 설정은 setSingleChoiceItems 에 두번째 인자로 지정할 수 있고 아무것도 지정하지 않으려면 -1 을 입력하면 된다.
[code]
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
[/code]
- 기본값 설정은 setSingleChoiceItems 에 두번째 인자로 지정할 수 있고 아무것도 지정하지 않으려면 -1 을 입력하면 된다.
[code]
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
[/code]
'Android' 카테고리의 다른 글
progress bar dialog (0) | 2013.10.08 |
---|---|
progress dialog (0) | 2013.10.08 |
creating an alertdialog (0) | 2013.10.08 |
onDismiss (0) | 2013.10.08 |
dismissing a dialog (close dialog) (0) | 2013.10.08 |