ActivityGroup代码

package com.hg.beyond;

import android.app.ActivityGroup;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

public class HomeActivityGroup extends ActivityGroup {
protected  static LinearLayout continer;
protected TextView title;
protected static HomeActivityGroup group;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

//去除actitity转换成view后的顶部的title阴影!
setTheme(android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);

requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
continer = (LinearLayout) findViewById(R.id.containerBody);
title = (TextView) findViewById(R.id.cust_title);
launchActivity();
group = this;
}

private void launchActivity() {
findViewById(R.id.btnModule1).setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// 去除所有的View
continer.removeAllViews();
continer.addView(HomeActivityGroup.this
.getLocalActivityManager()
.startActivity(
"one",
new Intent(HomeActivityGroup.this,
OneActivity.class)).getDecorView());
title.setText("转到第一个了");
title.setTextColor(Color.RED);

}
});
findViewById(R.id.btnModule2).setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// 去除所有的View
continer.removeAllViews();
continer.addView(HomeActivityGroup.this
.getLocalActivityManager()
.startActivity(
"two",
new Intent(HomeActivityGroup.this,
TwoActivity.class)).getDecorView());
title.setText("转到第二个了");
title.setTextColor(Color.BLUE);
}
});
findViewById(R.id.btnModule3).setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// 去除所有的View
continer.removeAllViews();
continer.addView(HomeActivityGroup.this
.getLocalActivityManager()
.startActivity(
"three",
new Intent(HomeActivityGroup.this,
ThreeActivity.class)).getDecorView());
title.setText("转到第三个了");
title.setTextColor(Color.GREEN);
}

});

}
}

你可能感兴趣的:(ActivityGroup)