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 8022499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:16:51+00:00 2026-06-04T22:16:51+00:00

Wondering if i can get some help with a problem i’m having? I have

  • 0

Wondering if i can get some help with a problem i’m having? I have searched for the answer on here, and although i found a few relevant topics i’m still really struggling…

Below you can see that i’m using a Spinner asking the user to select either Large, Med or Small.

The selection is then issued to a TextView.

What i now want to do is assign a value to the 3 selections, Large = 6, Med = 4, Small =2.
Next there will be a EditText box for the user to add their own value.
Then i want to put the two values into a calculation (say * them in this example) putting the answer into a TextView.

Any help here would be great.

Many Thanks
Will

String[] items = { "Large", "Med", "Small" };

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.plugfan);
    Factor = (TextView) findViewById(R.id.Factor);

    Spinner spin = (Spinner) findViewById(R.id.spinner);
    spin.setOnItemSelectedListener(this);

    ArrayAdapter aa = new ArrayAdapter(
            this,
            android.R.layout.simple_spinner_item, 
            items);

    aa.setDropDownViewResource(
       android.R.layout.simple_spinner_dropdown_item);
    spin.setAdapter(aa);
}

public void onItemSelected(AdapterView<?> parent, View v, int position,
        long id) {
    Factor.setText(items[position]);
}


public void onNothingSelected(AdapterView<?> parent) {
    Factor.setText("");
}
  • 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-06-04T22:16:53+00:00Added an answer on June 4, 2026 at 10:16 pm

    A quick way to solve this (not the smartest one) is to have a paralell array:

    int[] itemValues = { 6, 4, 2 };
    

    In the method onItmeSelected you can setText using the itemValue, instead of items.

    If you want a more OO-solution a new class that returns a list of Strings to use as a model for your spinner might be a beter solution (an enumeration might solve it too).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if i can get some help with this problem. Suppose I
I am wondering I can get some help at debugging or spotting the error
net and wondering if I could get some get help with this problem. The
Wondering if anyone can help me with this slight problem i'm having. I am
Starting a new GWT application and wondering if I can get some advice from
I know I can get answers here but I was wondering if anyone knows
I'm wondering if anyone can help me out with some Canvas. I'm pretty new
I was wondering if someone can help me solve the following problem. Someone has
I was wondering if sanyone could help me with the following: I have some
I am having trouble with my game and was wondering if anyone can help?

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.