在应用中,可能会在当跳转到另外一个Activity的时候需要传递数据过去,这时就可能用Bundle对象;
在MainActivity中,有一个导航至BActivity的Intent,
Intent
Intent intent = new Intent(Context context, Class<?> class);
//new一个Bundle对象,并将要传递的数据导入,Bunde相当于Map<Key,Value>结构
Bundle bundle = new Bundle();
bundle.putString(\"name\",\"Livingstone\");
bundle.putXXX(XXXKey, XXXValue);
//将Bundle对象添加给Intent
intent.putExtras(bundle);
//调用intent对应的Activity
startActivity(intent);
}
本文地址:https://www.stayed.cn/item/18353
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我