我正在尝试使用保留我的活动配置
@Override
public Object onRetainNonConfigurationInstance() {
// TODO Auto-generated method stub
ArrayList<String> array = new ArrayList<String>();
array = alarmsArrayList;
return array;
}
当我尝试
ArrayList<String> data = (ArrayList<String>) getLastNonConfigurationInstance();
if (data.size() != 0)
{
alarmsArrayList = data;
alarmList.setAdapter(adapter);
startProgress(SingleAlarm.this.getCurrentFocus());
}
else
{
startProgress(SingleAlarm.this.getCurrentFocus());
}
它给出了一个Null Pointer Exception
.
有没有办法保留 Activity 的每个配置,比如 CheckBox 状态?