Bundle 如何傳遞數(shù)據(jù)
1 回答

星箜下
TA貢獻(xiàn)34條經(jīng)驗(yàn) 獲得超10個贊
Bundle是一個數(shù)據(jù)的集合,就跟快遞打個包一樣。根據(jù)Google的API對Bundle的說明:A mapping from String values to various Parcelable types。通過鍵值對存儲數(shù)據(jù)。在Android中實(shí)現(xiàn)Parcelable接口的任意對象就能在Activity之間或者網(wǎng)絡(luò)上等傳遞,你要傳遞多個對象就該用Bundle包裝起來。最常用的就是
?Bundle bundle = new Bundle();
bundle.putParcelable("key",MyObject);
intent.putExtra(bundle);
startActivity(getContext(),XX.class);
//得到
Bundle bundle = getIntent().getExtra();
MyObject m = bundle.getParcelable("key");
- 1 回答
- 0 關(guān)注
- 1254 瀏覽
添加回答
舉報
0/150
提交
取消