0

I want to save listview message adapter state to force changing orientation. For example, user can see last message he saw after changing orientation of the device I tried onsaveinstance for this, but I think it doesn't work for the message adpater and this is my code.

   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);

    }
ndmeiri
  • 4,979
  • 12
  • 37
  • 45

0 Answers0