android - Best practice for handling state change during screen rotation -


i've got simple program spinner , togglebutton. when button toggled on disable spinner, , enable when toggle off. i've come across issue means spinner re-enabled during screen rotation. understand due activity state changing , oncreate being called again, haven't come across definitive answer on best practice view states in instances this.

note: relevant questions relating i've found below. 3 have discussions on how handle state changes (onpause/onresume versus overriding onsaveinstancestate), none seem clarify preferred option simple this.

losing data when rotate screen

saving android activity state using save instance state

android checkbox -- restoring state after screen rotation

the accepted answer @ saving android activity state using save instance state way go.

use onsaveinstancestate save boolean flag indicating whether spinner disabled, read flag in oncreate (or onrestoreinstancestate) , disable spinner necessary.

if give views android:id in xml layout , don't explicitly set android:saveenabled false, "state" saved , restored automatically. example, text views, includes text in view , position of cursor. appears enabled/disabled status not part of "state", however.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -