开发者

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.


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


}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜