다음과 같이 3개의 버튼을 가진 AlertBox를 만들었습니다. 리스트박스의 항목을 누를때 마다 팝업창이 뜨도록 만들었습니다.
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// prepare the alert box
AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
// set the message to display
alertbox.setMessage("detailed information");
// set a positive/yes button and create a listener
alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
}
});
// set a negative/no button and create a listener
alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
}
});
// set a neutral button and create a listener
alertbox.setNeutralButton("Any", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
}
});
// display box
alertbox.show();
}
이 때, 버튼을 하나만 더 넣었으면 하는데, 물론 버튼 두개씩 두줄로 나오면 터치할 수 있는 공간이 더 확보되겠죠. 그런 4개 버튼을 가진 팝업창을 만들 수 있을까요? 고수님들의 답변 기다립니다.
setView()로 layout을 붙일 수 있습니다. 버튼 4개짜리 layout을 만들어 구현 하시면 될 것 같네요