美文网首页
Activity onActivityResult传值

Activity onActivityResult传值

作者: 我叫杨毅 | 来源:发表于2018-05-15 09:43 被阅读9次

    0.跳转页

    Intent intent =new Intent(BasicDataActivity.this,CityPickerActivity.class);

    startActivityForResult(intent,110);

    startActivity(CityPickerActivity.class);

    1.传值页

    Intent cityData =new Intent(this, BasicDataActivity.class);

    cityData.putExtra("cityContent", city);

    setResult(1111, cityData);

    2.接收页

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {

    case 1111:

    String city = data.getStringExtra("cityContent");

        homeTV.setText(city);

        Log.e("返回城市: ", "返回城市: "+city);

        break;

    }

    }

    相关文章

      网友评论

          本文标题:Activity onActivityResult传值

          本文链接:https://www.haomeiwen.com/subject/zecedftx.html