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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:16:18+00:00 2026-06-07T02:16:18+00:00

All- I have two spinners side by side. I want it to be so

  • 0

All- I have two spinners side by side. I want it to be so that if an item in spinner1 is selected, spinner2 is invisible and visa versa. In other words the user should only be able to select one spinner. Here is my code concerning the spinners:

 //Spinner 1
    List<String> spin1= new ArrayList() ;
    spin1.add("Select");
    spin1.add("1");
    spin1.add("2");
    spin1.add("3" );
    spin1.add("4");


    Spinner spinner1 = (Spinner) findViewById(R.id.houses);
    ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,
                R.layout.spinnerlayout, spin1);


    adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(adapter1);

    //Spinner 2
    List<String> spin2 = new ArrayList() ;
    spin2.add("Select");
    spin2.add("1");



    Spinner spinner2 = (Spinner) findViewById(R.id.hotels);
    ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this,
                R.layout.spinnerlayout, spin2);


    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner2.setAdapter(adapter2);

Sample code welcome. Thank you for your time.

  • 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-07T02:16:20+00:00Added an answer on June 7, 2026 at 2:16 am

    The idea is simple enough:

        spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if(position != 0)
                    spinner2.setVisibility(View.GONE);
                else
                    spinner2.setVisibility(View.VISIBLE);
            }
    
            public void onNothingSelected(AdapterView<?> parent) {}
        });
    

    And vica versa for spinner2. You’ll need to change the definitions of spinner1 and spinner2 so that they are visible to the whole class:

    public class ... {
        Spinner spinner1;
        Spinner spinner2;
    
        @Override
        public void onCreate() {
            spinner1 = ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need change background of all text that have two spaces from the start
I have two table emptable1(empid,status) emptable2(empid,week) i want to select all the empid whose
I have two Entities University courses Course students i want to access all the
I have two spinners one named cuisine and other area. I m calling the
I have two questions. Am I making a wrong assumption that all my javascripts
I have Two spinner(Subject and Chapter),I crate two table(Chapter,subject). I add all subject name
I have two entities // All details has been removed @Entity @Table(name = "A_TABLE_NAME")
I have two nsbuttons in my interface builder.For all of these three nsbuttons I
If I have two different arrays and all I can do is check whether
I have two LinkedLists, I'd like to move all elements which match some criteria

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.