我想保存列表视图消息适配器状态以强制更改方向。例如,用户可以在更改此设备的方向后看到他最后看到的一条消息,为此我尝试了onsaveinstance,但是我认为这对消息adpater无效,这是我的代码。
private ListView messageListView;
private MessageAdapter messageAdapter;
public static String LIST_INSTANCE_STATE = "State" ;
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(LIST_INSTANCE_STATE, messageListView.onSaveInstanceState());}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
messageListView.onRestoreInstanceState(state);
}