1

I am working on handling the change of screen orientation. In my onSaveInstanceState() method, I wanted to pass the ListAdapter itself in, and then read it back out in onCreate(). Is this the best way to handle an orientation change, or do I have to pass an ArrayList of all the objects in the listadapter, and use it to repopulate the listAdapter in onCreate()?

user1154644
  • 4,491
  • 16
  • 59
  • 102

2 Answers2

0

you can use below code in activity tag in manifest file

android:configChanges="keyboardHidden|orientation|screenSize"

or you should pass a arraylist from your objects in the listadapter and for passing arraylist you should parcle it .see my code here Android Parcelable Implementation with ArrayList<Object>

Community
  • 1
  • 1
0

You don't need to save ListView, you just had to store the data with which you are populating your ListView.

1- Here is the example

2- Here is another example

I hope this will help you out surely.

Thanks

SALMAN
  • 2,031
  • 1
  • 20
  • 18