Harinder
Harinder

Reputation: 11944

Android spinner value gets lost when i open new activity?

Android spinner value gets lost when i open new activity and come back from that activity to my previous one.how do i retain my spinner index?

Upvotes: 0

Views: 336

Answers (2)

Balaji.K
Balaji.K

Reputation: 4829

use activity life cycle methods to save the state of the Activity and restore the Activity state to the previous state. those methods are onPause(), onResume() http://developer.android.com/reference/android/app/Activity.html follow this link

Upvotes: 1

TofferJ
TofferJ

Reputation: 4784

You can override the onSaveInstanceState and onRestoreInstanceState methods in the Activity class and save/restore the value of your index.

http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)

Upvotes: 1

Related Questions