I have an alert dialog (image and text in each row), but it is too wide. How can I change the width of the dialog?
My code:
ListAdapter adapter = new AnimalAdapter(this, _options );
final AlertDialog.Builder ad = new AlertDialog.Builder(this);
ad.setTitle("Options");
ad.setSingleChoiceItems( adapter, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String selectedVal = _options[which].getVal();
options_selected_item = selectedVal;
dialog.dismiss();
}
});
ad.show();
I have tried adding ad.getWindow().setLayout(600, 400); before and after ad.show(); but I get
The method getWindow() is undefined for the type AlertDialog.Builder.
Take a look here at some of the solutions that I suggested. I give a code example and try to explain how it works.