Solvek
Solvek

Reputation: 5370

Adding to LinearLayout another Layout and handle this Layout in separate Activity

  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.

Upvotes: 1

Views: 2099

Answers (1)

Solvek
Solvek

Reputation: 5370

I found solution in other SOF question: 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);
  }


}

Upvotes: 4

Related Questions