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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:52:19+00:00 2026-06-13T16:52:19+00:00

I am trying to make a simple form activity in order to learn how

  • 0

I am trying to make a simple form activity in order to learn how to use the various components supplied by Eclipse. I was doing great until I got to the radio buttons.

The application allows a user to fill out an entire form and then click the send button. When the send button is clicked I create a new intent, pass all of the form data into the intent and start up a new activity to act as a sort of confirmation/summary page.

How do I go about retrieving which radiobutton the user has clicked? I have five in total.
Below is the code from my onCreate method.

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.feedback_scroll);

    //References to XML
    name = (EditText)findViewById(R.id.nameEntryBox);
    county = (Spinner)findViewById(R.id.countySpinner);

    //Set array adapter
    county.setAdapter(fillCountySpinner());
    submitBtn = (Button)findViewById(R.id.submitFormBtn);

    atmo1 = (RadioButton)findViewById(R.id.arad1);
    atmo2 = (RadioButton)findViewById(R.id.arad2);
    atmo3 = (RadioButton)findViewById(R.id.arad3);
    atmo4 = (RadioButton)findViewById(R.id.arad4);
    atmo5 = (RadioButton)findViewById(R.id.arad5);

    ser1 = (RadioButton)findViewById(R.id.srad1);
    ser2 = (RadioButton)findViewById(R.id.srad2);
    ser3 = (RadioButton)findViewById(R.id.srad3);
    ser4 = (RadioButton)findViewById(R.id.srad4);
    ser5 = (RadioButton)findViewById(R.id.srad5);

    rating = (RatingBar)findViewById(R.id.ratingBar1);

    //Add a listener to the submit button - Anonymous inner class
    submitBtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // Create a new Intent
            Intent i = new Intent(v.getContext(), FeedbackResults.class);

            choice = (String)county.getSelectedItem();
            //Add extra parameters

            //Name
            i.putExtra("name", name.getText());
            //County
            i.putExtra("county", choice);
            //Dob
            //Atmosphere
            i.putExtra("atmosphere", atmos);
            //Service
            i.putExtra("service", serv);
            //Rating
            i.putExtra("rating", rating.getRating());

            //Start new Activity that will display a review of the customers feedback
            startActivity(i);

            //Toast message
            Toast.makeText(v.getContext(), "Thank you for your feedback!", Toast.LENGTH_SHORT).show();

        }
    });
}

I was looking at another topic relating to my question on this site. They said to use a switch statement. I understand the logic with it and wrote in the methods to do this, but I don’t know how to pass the View variable to it..What is this view variable relating to?? THis is the method I wrote.

    public void onRadioButtonClicked1(View v){

    switch(v.getId()){
    case R.id.arad1:
        atmos = "1";
        break;
    case R.id.arad2:
        atmos = "2";
        break;
    case R.id.arad3:
        atmos = "3";
         break;
    case R.id.arad4:
        atmos = "4";
        break;
    case R.id.arad5:
        atmos = "5";
        break;
    }

}

Any feedback is very much appreciated!

  • 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-13T16:52:21+00:00Added an answer on June 13, 2026 at 4:52 pm

    Each group of radio buttons should be in a group, I assume you did this already in your XML file.

    Assuming that, then you get the ID of the checked radio button by doing:

    int id = ((RadioGroup)findViewById( R.id.radio_group )).getCheckedRadioButtonId();
    

    You can do that anywhere in an Activity, or if you’re using a Fragment, then you just need to put a getView() in it:

    int id = ((RadioGroup)getView().findViewById( R.id.radio_group )).getCheckedRadioButtonId();
    

    So I would change your onClick:

    public void onClick(View v) {
        // Create a new Intent
        Intent i = new Intent(v.getContext(), FeedbackResults.class);
    
        choice = (String)county.getSelectedItem();
        int id = ((RadioGroup)findViewById( R.id.radio_group )).getCheckedRadioButtonId();
        atmos = getAtmos( id );
        ...
    }
    
    private int getAtmos( int id ) {
        switch( id ) {
            case R.id.arad1:
                atmos = "1";
                break;
            case R.id.arad2:
                atmos = "2";
                break;
            case R.id.arad3:
                atmos = "3";
                 break;
            case R.id.arad4:
                atmos = "4";
            break;
            case R.id.arad5:
                atmos = "5";
                break;
        }
    
        return atmos;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a simple form, but it's working not so fine. This
I have a WPF form where I'm trying to make a simple input form.
I'm a total n00b to c++ and am trying to make a simple form
I'm trying make my first python app. I want make simple email sender form.
I'm trying to make a simple application form were user can input data like
I am trying to use MySQL, Perl and JS to make a simple registration
I'm trying to use Zend_Http_Client to make a simple post request on a site
I'm trying to make a simple search and return results in a paginated form.
I'm trying to do a simple form to add an activity with a name
I'm trying to make a simple form input field with an image INSIDE the

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.