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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:56:04+00:00 2026-06-18T02:56:04+00:00

I have 3 spinners in my xml.. 1. one is Product Name 2. one

  • 0

I have 3 spinners in my xml..

1. one is Product Name
2. one is Product Quantity.
3. and 3rd one is Discount

Now, i calling separate Listener for each one.. the problem is i want to use item quantity to calculate final price and i called spinner in all in same sequence which is i wrote Name,Quantity and Discount..

The listener of Quantity is called at last even though i wrote above Discount Spinner..i don’t know what’s happening..can anybody ever face this problem…Please help me..

This is my Spinner Listener:-

spnSelectItem.setOnItemSelectedListener(new OnItemSelectedListener() 
        {

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3)
            {
                strItem=spnSelectItem.getItemAtPosition(arg2).toString();           }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub

            }
        });

          ///This method called last..
        spnQty.setOnItemSelectedListener(new OnItemSelectedListener() 
        {

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3)
            {
                strQty=spnQty.getItemAtPosition(arg2).toString();

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub

            }
        });
     ///This method called before spnQty ..
     spnItemDiscount.setOnItemSelectedListener(new OnItemSelectedListener()
        {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
            {
                disc=round(Double.parseDouble(spnItemDiscount.getItemAtPosition(arg2).toString().replace("%", "")));

            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub

            }
        });
  • 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-18T02:56:05+00:00Added an answer on June 18, 2026 at 2:56 am

    Why not create a separate method to perform all calculation like this:

    private void calculatePrice() {
            String strItem = spnSelectItem.getSelectedItem().toString();
            String qty = spnQty.getSelectedItem().toString();
            String discount = spnItemDiscount.getSelectedItem().toString().replace("%", "");
    
            //perform calculate and update UI as you like
        }
    

    and then either make a single listener for all of three spinners or call them in all of them, e.g.:

    spnSelectItem.setOnItemSelectedListener(new OnItemSelectedListener() {
    
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
    
                //do some work, update UI or reset qty and discount spinner or whatever
                strItem = spnSelectItem.getItemAtPosition(arg2).toString();
    
                //call calulcate method
                calculatePrice();
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Android 2.3.3 I have two spinners, one populated using string-array from strings.xml (static) and
Hi I have one xml file successfully parsed my before. now i am change
I'm writting an Android app. I have several spinners. Each one shows an extra
I have one spinner in which few values are there from strings.xml and I
As of rite now all I have is one spinner with three options, what
I have two spinners in an activity, A and B. Each spinner uses an
I have three web Views next to one another, for display of seperate spinners.
In main.xml I would like to have a spinner1 with two radio buttons and
Ok so I am working on an android app and I have implanted spinners...
I have an Activity with 3 spinners. These spinners get their data from a

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.