views:

111

answers:

1
  1. I have an Activity which uses a layout with a LinearLayout in it.
  2. Now I want to create in runtime a subactivity which loads some other layout and add this layout as item of my LinearLatout.

How to do this? Please provide me with code example.

A: 

I found solution in other SOF question: http://stackoverflow.com/questions/2761577/android-start-an-intent-into-a-framelayout

Seems it is working for me:

public class FormActivity extends ActivityGroup {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.form);

    LocalActivityManager m = getLocalActivityManager();

    Intent intent = new Intent().setClass(this, ContactFieldActivity.class);
    Window w = m.startActivity("tratat", intent);

    View v = w.getDecorView();

    LinearLayout container = (LinearLayout)findViewById(R.id.fieldsContainer);
    container.addView(v);
  }


}
Solvek