其他分享
首页 > 其他分享> > Android Activity利用setResult赋值

Android Activity利用setResult赋值

作者:互联网

//传值
getIntent().putExtra("useraddress",userAddressBeanList.get(position));
setResult(10,getIntent());
finish();

接收的区域复写:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 2 && resultCode == 10) {
            userAddressBean = (UserAddressBean) data.getSerializableExtra("useraddress");
   
        }
    }

requestCode为Activity跳转时传的值:

startActivityForResult(new Intent(this, AddressManagementListActivity.class), requestCode);

resultCode为setResult传的值:

setResult(resultCode,Intent());

标签:int,requestCode,Intent,resultCode,Activity,Android,data,setResult
来源: https://blog.csdn.net/a1003434346/article/details/97264772