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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:43:10+00:00 2026-05-25T19:43:10+00:00

I FIGURED OUT WHAT I WAS DOING. I HAD THE VARIABLE NAME IN QUOTES

  • 0

I FIGURED OUT WHAT I WAS DOING. I HAD THE VARIABLE NAME IN QUOTES WITH THE REST OF THE URL STRING.

How do you save the value of a Radio button into a variable and use that variable later.

I can see the variable Day_Item in my LogCat and the value is in there but when try using Day_Item later it does not show the valuable.

Below is a section of my code that shows the buttons.

String Day_Item = null;
    public class SearchDB extends Activity {
        private static final String TAG = "MyApp";
        String start_log = "STARTED";
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.search_layout);


        final RadioButton radio_monday = (RadioButton) findViewById(R.id.monday);
        radio_monday.setOnClickListener(radio_listener);
cityspinner.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
     public void onItemSelected(AdapterView<?> parent, View view, int position,long arg3) 
     {
      int id = parent.getId();

       if (spinner2_count2 < spinner2_count1 ) {
           spinner2_count2++;  } 
          else 
          {
                 String city_spinner_log = "CITY SPINNER";
                 Log.d(TAG, city_spinner_log);

                    String item = cityspinner.getSelectedItem().toString();
                    String nameContentType = "name";
                    String cityURL = "GetRestaurant.php?day=Day_Item&city=" + item;
                    Log.d(TAG, cityURL);
                    String shop_data =  DataCall.getJSON(cityURL,nameContentType);
                    Log.d(TAG,  shop_data);
                    Bundle bundle = new Bundle();
                    bundle.putString("shopData", shop_data);

                       Intent myIntent = new Intent(SearchDB.this, ShowRestaurant.class);
                       myIntent.putExtras(bundle);
                       startActivityForResult(myIntent, 0);
           }


    }
      }

   //ONCLICKLISTENER that saves RADIO value into a variable.

    public OnClickListener radio_listener = new OnClickListener() {
        public void onClick(View v) {
            // Perform action on clicks

            RadioButton rb = (RadioButton) v;
            Day_Item = (String) rb.getText();
            Log.d(TAG,Day_Item);
            Toast.makeText(SearchDB.this, Day_Item, Toast.LENGTH_SHORT).show();
        }
    };
}
  • 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-25T19:43:11+00:00Added an answer on May 25, 2026 at 7:43 pm

    You would need a bit more code to get a good solid answer. Such as how is Day_Item allocated? And is it’s scope global? Are you calling it from another activity or the one it’s allocated within? These are just guesses at this point:

    1) Are you sure your onClickListener isn’t firing multiple times? Thus setting Day_Item to an undesired text or nothing at all?

    2) Rather a question/answer,

    “but when try using Day_Item later it does not show the valuable”

    I’m assuming this means that it is null? Well if it’s being set properly, and then it is being null’d… it either is being explicitly null’d by you somewhere (such as (1)) or else the allocation and scope are the issue area I believe…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've figured out how to set VC++ to compile code into a .lib file
I thought I had this all figured out, but now that I'm writing a
(I had already written this question out when I figured out the answer, so
EDIT Looks like I figured it out - I had to call paginate after
I'm doing joins incorrectly, and haven't figured out the proper way to get the
I've been doing a bunch of searching and reading today, and haven't figured out
I'm trying to figure out what a Java applet's class file is doing under
I can't seem to figure out what I am doing wrong here. I publish
A while ago I was trying to figure out a way of doing this
Can't for the life of me figure out what I'm doing wrong... Downloaded Kohaml

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.