如何更改/更新有关Android方向更改的对话框的自定义布局



im试图更改活动的configurationChange中的对话框的布局。我已经在常规布局文件夹中创建了2个布局,另一个在布局 - 陆地上创建了一个布局,如果设备的方向在景观或肖像中,我可以得到布局,然后单击以显示对话框。但是,如果我尝试在对话框显示使用中的自定义布局时尝试更改方向。

请帮助我。我不想使用dialogfragment来做到这一点,是否有一种更简单的方法来解决它,只需使用常规的AlertDialog。

谢谢。

您应该创建两个不同的布局,一个用于肖像,另一个用于景观。然后要求在方向更改上布局。

搜索警报对话框。
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();

最新更新