0

I'm pretty much new to Android Studio, with less than a month's experience. I'm aware of the activity life cycle and all the methods like onCreate, onPause, OnResume, onSaveInstanceState and onRestoreInstanceState.

I'm working on a news app that takes information from a JSON feed and shows the news headlines for various categories. I was able to display the info on the screen using a list view and a custom adapter. I also created a menu for different categories.

Using onSaveInstanceState, I was able to retrieve the category which I had selected after changing the device orientation. However, when I scroll down the list view until the very end and then change the device orientation, the list view goes up to the top.

Is there a way to save the scroll position before the device changes its orientation?

I've tried out all the solutions mentioned in this thread - Maintain/Save/Restore scroll position when returning to a ListView, but the bug isn't removed.

  • 3
    Just use this thread, it will solve your issue. https://stackoverflow.com/questions/3014089/maintain-save-restore-scroll-position-when-returning-to-a-listview – Talha Ahmed Dec 24 '19 at 06:58
  • @TalhaAhmed, I tried out a couple of those solutions. Both didn't work. However, nowhere device orientation was mentioned in those solutions. – Saankhya Mondal Dec 24 '19 at 07:34
  • Does this answer your question? [Maintain/Save/Restore scroll position when returning to a ListView](https://stackoverflow.com/questions/3014089/maintain-save-restore-scroll-position-when-returning-to-a-listview) – Edric Dec 24 '19 at 08:18
  • No, it did not. I think they are all solutions for returning to the scroll position after coming from another activity. There is no solution for device orientation. – Saankhya Mondal Dec 24 '19 at 08:21
  • You should check this solution https://stackoverflow.com/a/43704197/5792379 – Alimov Shohrukh Dec 24 '19 at 10:19

0 Answers0