有时候在设计软件的时候布局复杂的话不利于查看跟更改,这时候我们可以在新建几个Activity,然后用ActivityGroup l来管理这写Activity
package com.android.antking.abv;
import android.app.Activity;
import android.os.Bundle;
public class Activity1 extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity1);
}
}
package com.android.antking.abv;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
public class MyMain extends ActivityGroup {
/** Called when the activity is first created. */
Activity1 activity;
LinearLayout layout;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(this,Activity1.class);
layout=(LinearLayout)this.findViewById(R.id.linearLayout1);
//ActivityGroup管理Activity,Activity转为View
Window subActivity = this.getLocalActivityManager().startActivity("Activity",intent);
View view = subActivity.getDecorView();
layout.addView(view);
}
}