How to inflate a activity in my case?

别说谁变了你拦得住时间么 提交于 2019-12-24 03:09:57

问题


I would like to achieve this layout :

my main activity layout (main.xml);

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

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

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?


回答1:


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

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



来源:https://stackoverflow.com/questions/6675747/how-to-inflate-a-activity-in-my-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!