ActivityGroup 用法关键类

public class Main extends ActivityGroup implements OnCheckedChangeListener,
OnClickListener {
private RadioGroup pay_mothed;
private Button btn_back;
private LinearLayout container;
private boolean isLandscape = true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isLandscape = getIntent().getBooleanExtra(Constants.IS_LANDSCAPE, true);
setRequestedOrientation(isLandscape ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.main);
init();
}

/**
* 初始化界面
* */
private void init() {
btn_back = (Button) findViewById(R.id.btn_back);
btn_back.setOnClickListener(this);
pay_mothed = (RadioGroup) findViewById(R.id.pay_mothed);
pay_mothed.setOnCheckedChangeListener(this);
container = (LinearLayout) findViewById(R.id.contents);
SwitchActivity(R.id.zfb);// 默认打开支付宝
}

/**
* 点击监听的实现
* */
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_back:
// 点击返回按钮
break;
}
}

/**
* 点击切换的监听实现方法
* */
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
SwitchActivity(checkedId);
}

/**
* 切换 Activity

* @param Id
* */
void SwitchActivity(int id) {
container.removeAllViews();// 必须先清除容器中所有的View
Intent intent = new Intent();
switch (id) {
case R.id.zfb:
intent.setClass(Main.this, PayZFB.class);
break;
case R.id.czk:
intent.setClass(Main.this, PayCZK.class);
break;
case R.id.jwk:
intent.setClass(Main.this, PayJWK.class);
break;
case R.id.lkczk:
intent.setClass(Main.this, PayLKK.class);
break;
// case R.id.kjzf:
// intent = new Intent(Main.this,PayKJZF.class);
// break;
case R.id.charge_history:
intent.setClass(Main.this, ChargeHistory.class);
break;
}
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// Activity 转为 View
Window subActivity = getLocalActivityManager().startActivity(
"subActivity", intent);
// 容器添加View
container.addView(subActivity.getDecorView(), LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值