JBOSS 点滴

丰丰的博客

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");
          //执行事件
  }
 }

posted on 2015-05-23 16:59 半导体 阅读(192) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: