Search This Blog

Wednesday, September 14, 2016

Fragment - Truyền dữ liệu giữa các Fragment

Gửi 
Fragment fragment =newFragment();Bundle bundle =newBundle(); bundle.putInt(key, value); 
fragment.setArguments(bundle);Nhận
Bundle bundle =this.getArguments(); 
int myInt = bundle.getInt(key, defaultValue); 

Các fragment khác đều nhận đc nếu trùng key

No comments:

Post a Comment