Adding to LinearLayout another Layout and handle this Layout in separate Activity
- I 开发者_高级运维have an Activity which uses a layout with a LinearLayout in it.
- 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);
}
}
精彩评论