android跳转到另一个类再返回当前类和值
16lz
2021-01-25
android跳转到另一个类再返回当前类和值
第一步:在A类中点击按钮时调用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();//关闭当前窗口
第三类:
返回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");
//执行事件
}
}
更多相关文章
- 在android 中利用button 按钮设置监听事件
- 【Android(安卓)开发教程】使用Intent-Filter
- Android(安卓)自定义EditText输入框 带清空按钮
- 【Android(安卓)开发教程】解决Intent-Filter的冲突
- android 显示单选列表对话框 builder.setSingleChoiceItems
- Activity四种启动模式
- Android之FloatingActionButton使用
- Eclipse & Android(安卓)模拟器快捷键
- 安卓应用的界面编程(2)