Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7009521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:52:22+00:00 2026-05-27T21:52:22+00:00

I have created a spinner with 3 options: Beginner, Advanced and Pro. When one

  • 0

I have created a spinner with 3 options: Beginner, Advanced and Pro. When one of the options is selected, I want to create a toast and set a double. I need the double to use that value later on, to calculate with 2 other values from an edittext.
For developing purposes I want to set a textview with that value, to check it.
I have tried a few things, but I cant bring it work. The textview keeps displaying 0.0

Hope someone can help me.

My java code:

package tim.steunebrink.tab;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class AlbumsActivity  extends Activity{


private TextView ExpValue;
private double expchosen;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.albums_layout);

    ExpValue = (TextView) findViewById(R.id.ExpValue);

    Spinner spinner = (Spinner) findViewById(R.id.spinner_experience);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.experience_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    class MyOnItemSelectedListener implements OnItemSelectedListener {

        public void onItemSelected(AdapterView<?> parent,
                View view, int pos, long id) {
            if (pos == 0) {
                // Beginner
                Toast.makeText(parent.getContext(), "Beginner = 0.5", Toast.LENGTH_LONG).show();
                double expchosen = new Double("0.5");

            } else if(pos == 1) {
                // Advanced
                Toast.makeText(parent.getContext(), "Advanced = 1.0", Toast.LENGTH_LONG).show();
                double expchosen = new Double("1.0");

            } else {
                // Pro
                Toast.makeText(parent.getContext(), "Pro = 1.5", Toast.LENGTH_LONG).show();
                double expchosen = new Double("1.5");

            }


            ExpValue.setText(Double.toString(expchosen));

        }

        public void onNothingSelected(AdapterView<?> parent) {
            // Do Nothing
        }
    }

    spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
}   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:52:22+00:00Added an answer on May 27, 2026 at 9:52 pm

    Make these Changes

    class MyOnItemSelectedListener implements OnItemSelectedListener {
            double expchosen ;
            public void onItemSelected(AdapterView<?> parent,
                    View view, int pos, long id) {
                if (pos == 0) {
                    // Beginner
                    Toast.makeText(parent.getContext(), "Beginner = 0.5", Toast.LENGTH_LONG).show();
                    expchosen= new Double("0.5");
                } else if(pos == 1) {
                    // Advanced
                    Toast.makeText(parent.getContext(), "Advanced = 1.0", Toast.LENGTH_LONG).show();
                    expchosen = new Double("1.0");
                } else {
                    // Pro
                    Toast.makeText(parent.getContext(), "Pro = 1.5", Toast.LENGTH_LONG).show();
                    expchosen = new Double("1.5");
                }
                ExpValue.setText(Double.toString(expchosen));
            }
    
            public void onNothingSelected(AdapterView<?> parent) {
                // Do Nothing
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have created a spinner using the following code. I didn't set any
I have created a webservice in .net 2.0, C#. I need to log some
I have an application, which has a Spinner that I want populated with some
I have created a nice scientific calculator and now want to save inputs and
I am wanting to create a Spinner from an ArrayList of Objects I have
i have created a spinner.could i place my spinner items in a table into
hi I created one simple xml based spinner application.i got all value in my
I have created two input fields using EditText, a TimePicker , a Spinner along
I have a spinner that is created using the resource file statically. now i
I've created a custom adapter for my spinner because I wanted to have multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.