1. 程式人生 > >fragment之間傳遞資料

fragment之間傳遞資料

1,繫結資料
Bundle bundle = new Bundle();
//注意 arg應該implement 
serializeable
物件,要求容器儲存的物件要實現serializeable
serializeable介面,如果是集合,將集合物件強制轉換為Serizeable物件,要求容器儲存的物件要實現serializeable
bundle.putSerializable("asnReceiveDetails", arg);InStorageReceiptDetailFragment receiptFragment = new InStorageReceiptDetailFragment();receiptFragment.setArguments(bundle);
2,目標Fragment中接收資料
if (getArguments() != null && getArguments().getSerializable("asnReceiveDetails") != null) {
    List<WmRfAsnReceiveInfo>) getArguments().getSerializable("asnReceiveDetails"));
    
}