How do I reset an Android spinner?

hoss24

I am using a spinner as navigation for my app, and need to know how to reset it when the user uses the back button. Currently when a user selects a page and goes back, the spinner is on the previously selected bar, and not the current page. Here is my current code.

public void spinnerNavigation(){
    Spinner mySpinner = (Spinner) findViewById( R.id.spinner1);          
    mySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> adapter, View v, int i, long lng) {
            if (i == 0) {
                // current page         
            } else if (i == 1) { // Second item 
                Intent myIntent = new Intent(getBaseContext(), LearnActivity.class);
                myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(myIntent);                                
            } else if (i == 2) { // Third item
                Intent myIntent = new Intent(getBaseContext(), QuizActivity.class);
                myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(myIntent);
            } else if (i == 3) { // Fourth item
                Intent myIntent = new Intent(getBaseContext(), ForumActivity.class);
                myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(myIntent);
            }
        }
        public void onNothingSelected(AdapterView<?> arg0) {
            // Do nothing
        }
    }); 
}
fweigl

If you want to reset it to the first item:

mySpinner.setSelection(0); 
_____________________

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I center text in a spinner in Android

From Dev

How do I dim the background for an android spinner?

From Dev

How do I dim the background for an android spinner?

From Dev

How to reset selected item of a spinner in android?

From Dev

how do I bind database values to Spinner dropdownlist in android code?

From Dev

How do I "group" if statements to use in a spinner in Android Studio?

From Dev

How do I reset this variable?

From Dev

How do I reset a function?

From Dev

How do i hide the selected item of spinner

From Dev

How do I hide a Font Awesome spinner?

From Dev

Android : How can i Customize Spinner items?

From Java

How do I reset my reset the Currentstate of this application

From Dev

How do I reset input autocomplete styles?

From Dev

How do I reset CSS with jQuery?

From Dev

How do I reset all deleted files

From Java

How do I reset mocked values in Jest?

From Dev

How do I reset the thumbnail cache?

From Dev

How do i Meteor Reset client subscription

From Dev

How do i reset to my earlier commit?

From Dev

How do I reset GNOME to the defaults?

From Dev

How do I reset my keyboard layout?

From Dev

How do I reset MathJax settings in IPython?

From Dev

iOS how do I reset button images?

From Dev

How do I save a `git reset`

From Dev

How Do I Reset Language to Default Language

From Dev

How do I reset the image on a button in tkinter?

From Dev

How do I implement a password Reset Link

From Dev

How do I add a reset option to this game?

From Dev

How do I reset the colors of my terminal?