0

I know that any changes made to a view during runtime are not saved by default of screen rotation. So I persist all changes made to my custom listview row in onSaveInstanceState and restore them back in onRestoreInstanceState. But these methods are not being called at all on screen rotation.

Now I know that views need to have an ID assigned to be persisted across screen rotation. But ListView rows are created programmatically in getView method of adapter. Does this mean that I need to call setId in getView?

Hybrid Developer
  • 2,320
  • 1
  • 34
  • 55
iTwenty
  • 953
  • 8
  • 19
  • The method 'onSaveInstanceState' should be called on screen rotation. Where do you have implemented the method 'onSaveInstanceState'? – RaphMclee May 15 '14 at 08:22
  • Inside my custom listview row. There is a boolean flag which changes depending on whether the row has been clicked or not and I want to persist this flag across orientation changes. – iTwenty May 15 '14 at 08:34

1 Answers1

0

The onSaveInstanceState and onRestoreInstanceState have to be implemented in the activity or fragment.

Take a look at some other post on SO.

Community
  • 1
  • 1
RaphMclee
  • 1,623
  • 13
  • 16