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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:44:31+00:00 2026-05-18T02:44:31+00:00

Ok, I’m not great at explaining this as I’m new to Android so work

  • 0

Ok, I’m not great at explaining this as I’m new to Android so work with me.
I have tried everything I can find and I dont know how to make everything work together.
I have a Spinner to select an age group, a Radio group with Radio buttons to allow you to select Gender (male or female), I have an EditText that I will allow for numerical input and a Textview out to the side that is currently blank.

Depending on which age group is selected from the spinner and which one of the Radio buttons are selected – setText of the TextView to a certain number based on what number is entered in the EditText box.

Ive tried using OnItemSelectedListener for the spinner but havent been able to find how it knows what is selected from the array.I tried getItemSelected with an if statement with the item from the array

for the radio button
Ive tried using an if statement – if (radiobutton.isChecked()) but I didnt know if I
needed an ifCheckedRadio before this and how to make it work after the spinner

and if all of this worked I had
if (EditText.getText().equals(“#”))
TextView.setText(“#”);

This will be copied for each possible # entered

now would the text change like this without a button and OnClickListener or is there a way to do this without a button becuase there will more than one EditText that will be added at the end using a button but I wanted this displayed immediately after it is entered

Sorry if this isnt clear, please let me know if you need more information. If I’ve overlooked a previous question that uses spinners and radiobuttons please let me know and I’ll keep looking but I’ve been stuck on this.

  • 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-05-18T02:44:32+00:00Added an answer on May 18, 2026 at 2:44 am

    OK – re your last comment, this makes both selecting an item from the spinner and the radio buttons, terminating actions for input. Basically I’ve added onClickListeners to the buttons. You can’t really add an Onclick to the edit text though, as a click normally brings up the soft keyboard.

    package com.test.spinnerexample;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.EditText;
    import android.widget.RadioButton;
    import android.widget.Spinner;
    import android.widget.TextView;
    import android.widget.AdapterView.OnItemSelectedListener;
    
    public class SpinnerExample extends Activity {
    RadioButton rb1; RadioButton rb2; TextView tv;  EditText et;
    Spinner sp;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 
        rb1 = (RadioButton) findViewById(R.id.RadioButton01);
        rb2 = (RadioButton) findViewById(R.id.RadioButton02);
        tv = (TextView) findViewById(R.id.OutputText);
        et = (EditText) findViewById(R.id.EditText01);
        sp = (Spinner) findViewById(R.id.Spinner01);
        ArrayAdapter<CharSequence> adapter1;
        adapter1 = ArrayAdapter.createFromResource(
                this, R.array.agegroups_array,
                android.R.layout.simple_spinner_item);
        adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        sp.setAdapter(adapter1);
        rb1.setChecked(true);
        sp.setOnItemSelectedListener(new MyOnItemSelectedListener());
        rb1.setOnClickListener(new ButtonListener());
        rb2.setOnClickListener(new ButtonListener());
    }
    private class MyOnItemSelectedListener implements OnItemSelectedListener {
    
        public void onItemSelected(AdapterView<?> parent, View view, int pos,
                long id) {
    
            RadioButton checkedButton = rb1.isChecked() ? rb1 : rb2;
            showResult(parent.getItemAtPosition(pos).toString(),
                    checkedButton.getText().toString());
        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    }
    private class ButtonListener implements OnClickListener{
    
        @Override
        public void onClick(View view) {
            RadioButton rb = (RadioButton) view;
            int selectedItem = sp.getSelectedItemPosition();
            showResult(sp.getItemAtPosition(selectedItem).toString(), 
                    rb.getText().toString());
        }
    
    }
    private void showResult(String selctdSpnrText, String chkdBtnText){
        String answer = selctdSpnrText + " " + chkdBtnText + " "
        + et.getText();
        tv.setText(answer);
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build

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.