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

  • Home
  • SEARCH
  • 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 8362069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:51:25+00:00 2026-06-09T11:51:25+00:00

I have a question about spinners, and cannot find anything online about how to

  • 0

I have a question about spinners, and cannot find anything online about how to do it.

I have a spinner in my app, with region selections i.e. Southwest, Southeast.

I want the spinner to selections available of the second spinner to be dependent on the selection made in the first one. i.e. When the user selects Southwest the choices on the second spinner would be Lake Charles, Iowa, Lake Arthur etc. And when the user selects southeast, the choices of the second spinner would be Gretna, New Orleans, Luling etc.

how do I go about doing that?

examples would be greatly appreciated!

Thank you!

  • 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-09T11:51:26+00:00Added an answer on June 9, 2026 at 11:51 am

    Try this Code..

    I hope it will helpful to you…

    public class MainActivity extends Activity {
    
    Spinner sp1,sp2;
    ArrayAdapter<String> adp1,adp2;
    List<String> l1,l2;
    int pos;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        l1=new ArrayList<String>();
    
        l1.add("A");
        l1.add("B");
    
        sp1= (Spinner) findViewById(R.id.spinner1);
        sp2= (Spinner) findViewById(R.id.spinner2);
    
        adp1=new ArrayAdapter<String> (this,android.R.layout.simple_dropdown_item_1line,l1);
        adp1.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
        sp1.setAdapter(adp1);
    
        sp1.setOnItemSelectedListener(new OnItemSelectedListener() {
    
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                // TODO Auto-generated method stub
                pos=arg2;
                add();
    
            }
    
            private void add() {
                // TODO Auto-generated method stub
                Toast.makeText(getBaseContext(), ""+pos, Toast.LENGTH_SHORT).show();
    
                switch(pos)
                {
                case 0:
                    l2= new ArrayList<String>();                    
                    l2.add("A 1");
                    l2.add("A 2");
    
                    adp2=new ArrayAdapter<String>(MainActivity.this,
                            android.R.layout.simple_dropdown_item_1line,l2);
                    adp2.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
                    sp2.setAdapter(adp2);
    
                    select();
    
                    break;
                case 1:
                    l2= new ArrayList<String>();                    
                    l2.add("B 1");
                    l2.add("B 2");
    
                    adp2=new ArrayAdapter<String>(MainActivity.this,
                            android.R.layout.simple_dropdown_item_1line,l2);
                    adp2.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
                    sp2.setAdapter(adp2);
    
                    select();
    
                    break;
                }
    
            }
    
            private void select() {
                // TODO Auto-generated method stub
    
                sp2.setOnItemSelectedListener(new OnItemSelectedListener() {
    
                    @Override
                    public void onItemSelected(AdapterView<?> arg0, View arg1,
                            int arg2, long arg3) {
                        // TODO Auto-generated method stub
                        Toast.makeText(getBaseContext(), "Test "+arg2, Toast.LENGTH_SHORT).show();
    
                    }
    
                    @Override
                    public void onNothingSelected(AdapterView<?> arg0) {
                        // TODO Auto-generated method stub
    
                    }
                });
    
            }
    
            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub
    
            }
        });
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about parsing a specific json string. I didn't find anything which
I have this question about umbraco structuring and I can't find the answer anywhere.
I have question about integrate Open office with PHP. I want make mail merge
I have question about why 2 controls in separate repeaters cannot have the same
Hello I have question about android spinner I have spinner which is populated by
Hello I have question about android spinner I have spinner which is populated by
I have question about python and sqlite3. I want to drop a table from
I have question about regexp in TCL. How i can find and change some
Have a question about linux bash. I want to start a program and then
I have question about parsing in Html helper : I have sth like: @foreach

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.