通过bundle传递参数的时候,在新的页面接收参数,可以通过
发送页面传递参数:
Bundle todetailBundle = new Bundle();
todetailBundle.putString("inter_id", inter_id);
WeihuEditDetail weihuEditDetail = new WeihuEditDetail();
FragmentManager fm1 = getFragmentManager();
FragmentTransaction ft1 = fm1.beginTransaction();
weihuEditDetail.setArguments(todetailBundle);
ft1.replace(R.id.frag_container_linearyout,
weihuEditDetail, "weihueditdetail");
ft1.commit();
接收方判断bundle是否含有所传的值,如果有值对值进行读取和赋值操作:
private String inter_id_tobeedit;
if(bundle!=null&&bundle.containsKey("inter_id")){
inter_id_tobeedit = bundle.getString("inter_id");
}
本文详细介绍了如何使用Bundle在不同页面之间传递参数,包括如何在发送页面创建Bundle,添加参数,并在接收页面解析和使用这些参数。重点阐述了在Android应用中利用Bundle进行数据共享的方法。
1927

被折叠的 条评论
为什么被折叠?



