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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:08:22+00:00 2026-06-12T21:08:22+00:00

Spinner spinner, spinner2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_check_box_tuts); spinner = (Spinner)findViewById(R.id.spinner1);

  • 0
Spinner spinner, spinner2;


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

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

    }
    @Override
    public void onItemSelected(AdapterView<?> v, View arg1, int arg2,
            long arg3) {
        switch(v.getId()){
        case R.id.spinner1:
            if(spinner.getSelectedItemPosition() == 1){
                //what goes here??
            break;
        }
        }
    }

Like my first spinner lists are countries : USA, JAPAN etc.. so after USA has been selected for example, my second spinner would able to get a list of USA’s state array..

I use my newbie logic to try to think this way : set the 2nd spinner to View.GONE, then if lets say USA is selected, show the spinner2 which it alone carry the states.. but if I have 60 countries, then I must have 60 spinner, that’s funny so help me 😀

  • 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-12T21:08:23+00:00Added an answer on June 12, 2026 at 9:08 pm

    Rather than creating a Spinner for each country instance, keep the same Spinner, and replace the data stored in it when a value is selected from your first Spinner with
    ArrayAdapter.createFromResource() and Spinner.setAdapter(). Here is an example using those two calls.

    Rather than hiding your second Spinner before an option is selected in the first, consider having a default selection in the first Spinner, and populating the second with the matching data. In your example, USA would be a good default selection.

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

Sidebar

Related Questions

I am creating a spinner in my current layout file, and the contents of
I have a ListView ,checkbox and spinner in one layout , and on different
I have a problem changing the items from spinner1 to spinner2 . Ok im
Hi I have a spinner (spinner5) and whenever the user selects an item that
in my spinner i am trying to attach an image and a text View,
I have a Spinner.onItemSelected() method and I want to be able to have an
How to make spinner to fill empty place in left side? android:layout_width=fill_parent does not
I have a spinner witch is populated from database, when I select an item
I have checkBox and Spinner . If the checkbox is checked, then spinner should
If i change the Spinner width like below only the up/down arrow place is

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.