Brighton Vino
Brighton Vino

Reputation: 395

Android Spinner Saving Last Selected Option

I have a Spinner in my Activity with a list of Options. By default my first Item on the list is in Selected State when I start the Activity.

Assume My List has <Circle> <Square> <Rectangle> <Triangle>

When Activity is created for the first time Circle is Selected. Suppose I select Rectangle. Then I navigate to another Activity and then recreate the Activity. My selection is restored to the first Item again. How can I save my previous selected option.

Upvotes: 0

Views: 860

Answers (1)

djg
djg

Reputation: 1283

What are the Object types in your list? Strings?

Try overriding onSaveInstanceState and onRestoreInstanceState

This answer has a nice example: Saving Android Activity state using Save Instance State

Upvotes: 1

Related Questions