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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:36:50+00:00 2026-06-01T11:36:50+00:00

I tried to ask this question before but I guess I didnt explain myself

  • 0

I tried to ask this question before but I guess I didnt explain myself properly, so I will try again. I have a spinner (spinner5), I have created two string arrays (name_array and type_array) which are inside the values folder.

I also have two radio buttons (radiobtn1 and radiobtn2). I want to basically change the source of spinner5 when each radio button is selected.

if (radiobtn1 is selected)
then
  I want spinner5 to display contents from name_array.

else If (radiobtn2 is selected)
then 
  I want spinner5 to display contents from the type_array.

Hope someone can help. Thanks

  • 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-01T11:36:51+00:00Added an answer on June 1, 2026 at 11:36 am
        Write below code in xml
    
        <RadioGroup 
             android:layout_toRightOf="@+id/txtpref"
             android:layout_marginLeft="10sp"
             android:orientation="horizontal"
                 android:layout_width="wrap_content" 
             android:layout_height="wrap_content">
            <RadioButton 
                android:textColor="#000000"
                android:text="Male" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:id="@+id/radiobutton1"/>
            <RadioButton 
                android:textColor="#000000"
                android:text="Female"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:id="@+id/radiobutton2"/>    
        </RadioGroup> 
    
    
        In Your Java file
    
        RadioButton radiobutton1,radiobutton2;
        String [] name_array,type_array;
        String [] temparray;
    
        temparray = (name_array or type_array) // use any which you want disaplay first and use temparray to pass your adapter 
    
    ArrayAdapter arrayAdapter =new ArrayAdapter<String>(Activity_Name.this,android.R.layout.simple_spinner_item, temparray);
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it‌​em);
    
        radiobutton1 = (RadioButton) findViewById(R.id.radiobutton1);
        radiobutton2 = (RadioButton) findViewById(R.id.radiobutton2);
    
        radiobutton1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        // TODO Auto-generated method stub
                        if (isChecked) {
                        // you want spinner5 to display contents from name_array.   
                                         temparray = name_array;
                                         your_adapter.notifyDataSetChanged();
                        }
                    }
            });
    
        radiobutton2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        // TODO Auto-generated method stub
                        if (isChecked) {
                        // you want spinner5 to display contents from type_array.   
                                         temparray = type_array;
                                         your_adapter.notifyDataSetChanged();
                        }
                    }
                });
    
    
        Thanks
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry to ask this question again but I tried several solutions on stackoverflow and
I have tried to ask a variant of this question before. I got some
I tried to ask this question once before, but nobody understood what I want
Before I ask this question I must point out that I have tried to
I tried to ask this before, and messed up the question, so I'll try
Well, I tried to ask this question as a comment on this question, but
I want to ask,i tried to call webapp.RequestHandler ,but this handler didn't called: this
This is a complete noob question, but I gotta ask it anyway I started
This question has been asked many times before but none of the previous ones
i already search here before i ask this question.. I know there is an

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.