2

I would like to achieve this layout :

my main activity layout (main.xml);

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

enter image description here

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:

enter image description here

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?

Mellon
  • 37,586
  • 78
  • 186
  • 264

1 Answers1

2

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

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

Kumar Bibek
  • 9,016
  • 2
  • 39
  • 68
  • @ kumar Bibek , is fragment only supported by android 3.0 ? If I am using android 2.1 updated, can I use fragment? – Mellon Jul 13 '11 at 08:23
  • Yes you can, by using the Fragments static library. http://developer.android.com/sdk/compatibility-library.html – Kumar Bibek Jul 13 '11 at 08:51