gpt4 book ai didi

java - 将 bundle 从 recyclerview 适配器传递到 Activity

转载 作者:太空宇宙 更新时间:2023-11-04 13:00:11 26 4
gpt4 key购买 nike

我想通过单击按钮将 bundle 传递给新 Activity 。这是类适配器中bundle的代码,它扩展了recycleview适配器

private void passBundle (Vendor mItemSelected){
mBundle = new Bundle();
mBundle.putString("VENDOR_ID", mItemSelected.getVENDORID());
mBundle.putString("CAT_ID", "" + mItemSelected.getVEN_TYPE());
mBundle.putString("VENDOR_NAME", "" + mItemSelected.getVENDORNAME());
mBundle.putString("CAT_ID", "" + mItemSelected.getVEN_TYPE());
mBundle.putString("CAT_ID", "" + mItemSelected.getVEN_TYPE());
mBundle.putString("VENDOR_AREA", "" + mItemSelected.getVENDORADDRESS());
Intent in = new Intent(context,Chat_Activity.class);
in.putExtra("Bundle", mBundle);
Context.startActivity(in);
}

这是我在另一个 Activity 中检索 bundle 数据的代码。

Bundle bundle = new Bundle();
chatVenID = bundle.getString("VENDOR_ID", "");
catID = bundle.getString("CAT_ID", "");
vendorName = bundle.getString("VENDOR_NAME", "");
vendorArea = bundle.getString("VENDOR_AREA","");

最佳答案

Bundle bundle = new Bundle();

在此代码中,您正在创建一个新的 Bundle 对象,因此您不会获得任何值。将其更改为

getIntent().getBundleExtra("Bundle")

关于java - 将 bundle 从 recyclerview 适配器传递到 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35007764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com