android - how to retain state of listview during orientation changes? -
Hello friends, after reading the title of my question, I know that you are easy to answer, but as I New in Android development, I find it difficult to maintain the state of the list view while changing orientation, and even in the fragment state, I surf a lot on Google but I retire the state during orientation changes. There is no satisfactory solution for me, I know that they have an onsite investistate () method in which you have to enter each of your visual data, but I think that they have a better solution, so please solve it Help me find You can also provide a link to a good tutorial on Orientation changes. Thanks in advance
-
I've found that, depending on your implementation, the list view position is saved by default, but to restore the state, rebuild the listview and make sure that with
savedInstanceStateOne of the methods is called later as a parameter (Not before). Why? Since the list view state has been saved, the super method restores it and you can override the restored status if you are restarted after calling the super. -
Another method is override
onSaveInstanceState (Outstate)of activity, put the list view in bundle,Outstate Output ("listview.state", listview.onSaveInstanceState ());Then when you override
onRestoreInstanceState (Saved InstanceStat), you call the list after redialing the call;Parcelable list viewstats = Saved InstantState getParcelable ("listview.state"); Listview.onRestoreInstanceState (listViewState);
Check for zero values and good luck!
Comments
Post a Comment