1

Im trying to change the layout of a Dialog in the onConfigurationChange of the activity. I have created 2 layout one in regular layouts folder and other in layouts-land, i can get the layouts if the orientations of the device is in landscape or portrait and then click to show the dialog. But if I try to change the orientation when the dialog is showing the custom layout in using is not updating.

Please help me out with this. I don't wanna use a DialogFragment to do this, is there a easier way to fix it by just using regular AlertDialog.

Thanks.

1 Answer 1

-1

You should create two different layouts, one for portrait and another for landscape. Then call for layout on orientation change. Search for alert dialog with own layouts.

LayoutInflater inflater = getLayoutInflater();
View alertLayout = inflater.inflate(R.layout.layout_custom_dialog,null);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Info");
alert.setView(alertLayout);
AlertDialog dialog = alert.create();
dialog.show();
1
  • Hi Anuj, thats exactly what im doing.. but the layout is not updating on orientation change.. It works in Portrait or in Landscape but transaction is not working.
    – Adithya.K
    Feb 15, 2018 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.