Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get back to default value in spinner onclick?

Tags:

android

My spinner coding is something like this:

    assetSpinner = (Spinner) findViewById(R.id.editAsset);
    assetAdapter = ArrayAdapter.createFromResource(
            this, R.array.asset_array, android.R.layout.simple_spinner_item);
    assetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    assetSpinner.setAdapter(assetAdapter);

Now I have a reset button in my design. So my question is when I click on reset button how to make the spinner get back to default value or reset the spinner.

like image 712
Suleman Khan Avatar asked Jan 04 '12 07:01

Suleman Khan


1 Answers

You can using Spinners setSelection attribute to reset your Spinner to its original position. spinner.setSelection(position);

like image 172
Lalit Poptani Avatar answered Oct 08 '22 00:10

Lalit Poptani