Am cố gắng để lưu trữ giá trị của một ArrayList trong onSavedInstanceState()
và nhận được các giá trị trong một danh sách mảng trong phương pháp onCreate nhưng nó đặt ra một eeror như không thể tạm dừng hoạt độngLàm thế nào để lưu trữ các giá trị trong onSaveInstanceState() và thử lại?
đây là mã của tôi
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putParcelable("Old", (Parcelable) profileDetails);
super.onSaveInstanceState(savedInstanceState);
}
và trong tôi onCreate()
if (savedInstanceState != null) {
profileDetails= (ArrayList<ProfileDetails>)savedInstanceState.getParcelable("Old");
}
else {
profileDetails = GetSearchResults();
}
Tôi sẽ thử và cho bạn biết! –