开发者

How to inflate a activity in my case?

开发者 https://www.devze.com 2023-03-20 03:19 出处:网络
I would like to achieve this layout : my main activity layout (main.xml); (Please mouse right click the following image and view image)

I would like to achieve this layout :

my main activity layout (main.xml);

(Please mouse right click the following image and view image)

How to inflate a activity in my case?

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:

How to inflate a activity in my case?

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);

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

0

精彩评论

暂无评论...
验证码 换一张
取 消