how to show alert box button in vertical orientation in android?
I have one image button, when i click it opens 3 dialogbox buttons and they come in horizontal way. I want that alert dialog box button comes to vertic开发者_运维技巧al. How?
try this simple method
public void verticalAlert (final String item01, final String item02, final String item03){
String[] array = {item01,item02,item03};
AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
builder.setTitle("Test")
.setItems(array, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
switch (which) {
case 0:
// case item 1 do...
break;
case 1:
// case item 2 do...
break;
case 2:
// case item 3 do...
break;
}
}
});
builder.show();
}
You can use View in the Alertdialog's setview method. In that View,call the View's LAYOUT_INFLATER_SERVICE and use a customized xml as per your requirement.
精彩评论