我使用 ListFragment
设置保留实例(真);不起作用,我不知道为什么
已保存实例状态 == 空
我的消息来源
public class Fragment_Left extends ListFragment {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Log.d(LOG_TAG, "Fragment1 onAttach");
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(LOG_TAG, "Fragment1 onCreate");
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setRetainInstance(true);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
getListAdapter().getItem(position);
}
public void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
Log.i(LOG_TAG, "onSaveInstanceState()");
}
}
public class Fragment_Left extends ListFragment {
private ArrayList<Menu_item> menu_list; .....
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setRetainInstance(true);
menu_list = new ArrayList<Menu_item>();......
但是在我打开屏幕之后 menu_list 为空,或者我做错了什么?