android跳轉(zhuǎn)到另一個(gè)類再返回當(dāng)前類和值
第一步:在A類中點(diǎn)擊按鈕時(shí)調(diào)用B類A類中:
int OUTBILL_CODE = 10;//全局啊
case R.id.diyoutbill:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(ctx, Itemdiydown.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(intent,OUTBILL_CODE);
break;
第二步:
B類中:
Bundle bundle = new Bundle();
bundle.putString("downtype",pubdowntype);
bundle.putString("startDate",pubstartDate);
bundle.putString("endDate", pubendDate);
Itemdiydown.this.setResult(RESULT_OK, this.getIntent().putExtras(bundle));
Itemdiydown.this.finish();//關(guān)閉當(dāng)前窗口
第三類:
返回A類中:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == OUTBILL_CODE&& resultCode == RESULT_OK) {//
Bundle bundle = data.getExtras();
startDate = bundle.getString("startDate");
endDate = bundle.getString("endDate");
downtype = bundle.getString("downtype");
//執(zhí)行事件
}
}
posted on 2015-05-23 16:59 半導(dǎo)體 閱讀(202) 評(píng)論(0) 編輯 收藏