在Android的动态加载的布局 [英] Dynamically load layout in Android

查看:130
本文介绍了在Android的动态加载的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要2个屏幕,为此我已经尝试使用创建了两个不同的 XML 布局文件 RelativeLayout的。每当我跑我的活动一布局文件加载。现在,我要加载的第二个布局到同一活动,当用户在 OptionsMenu 点击一个按钮,也当用户preSS后退按钮的第一个屏幕负载,而不是退出应用程序。所以,我不需要在我的应用程序创建另一个意图

My application requires 2 screens and for this I have created two different XML layout files using RelativeLayout. One layout file loads whenever I run my Activity. Now I want to load the second layout on to the same Activity , when user click on a button in OptionsMenu and also when user press Back button the first screen loads instead of exiting the application. So that i don't need to create another Intent in my application.

推荐答案

在理想情况下应该有两个不同的活动,present在您的应用程序。 您可以添加或视图中删除一个视图组件,但如果你正在寻找两个完全不同的画面,那么我建议你去一个新的活动。

Ideally there should be two different activities present in your application. You can add or remove a view component in a view but if you are looking for two completely different screens then i would suggest you to go for a new activity.

我不力让你叫并且,当用户preSS柬埔寨王国律师协会按钮,第一屏的负载,而不是退出应用程序

I dint get what you meant by "and also when user press Bakc button the first screen loads instead of exiting the application"

如果你不希望显示的第一个画面只是完成()的活动。

If you dont want to show the first screen just finish() the activity.

这篇关于在Android的动态加载的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆