如何在膨胀的情况下我的一个活动? [英] How to inflate a activity in my case?

查看:132
本文介绍了如何在膨胀的情况下我的一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现这个布局:

我的主要活动的布局(的main.xml );

my main activity layout (main.xml);

请鼠标右键点击下面的图片,查看图片

我已经做了另一个 ContentActivity (与内容设置为 content_one.xml ),这应该是作为上述布局的一部分(右部分):

I have made another ContentActivity (with content set to content_one.xml) which is supposed to be used as part (the right part) of the above layout:

我知道我可以膨胀的布局:

I know I can inflate a layout by:

LinearLayout mainLayout =  (LinearLayout) findViewById(R.id.main);

LayoutInflater inflater = (LayoutInflater)Home2.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View inflatedView = (View) inflater.inflate(R.layout.content_one, null);

mainLayout.addView(inflatedView);

我想知道,除了充气content_one布局为主要布局,是有可能夸大一个活动类,而不是一个充气布局的Andr​​oid ?如果可能的话,该怎么办呢?

I am wondering, besides inflate the content_one layout into main layout, is it possible to inflate a activity class instead of inflating a layout in android? If possible, how to do it?

推荐答案

您不能夸大一个活动本身。考虑使用片段。

You cant inflate an Activity as such. Consider using Fragments.

http://developer.android.com/guide/topics/fundamentals/ fragments.html

这篇关于如何在膨胀的情况下我的一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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