Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Ecplipse Java: using radio buttons to bring new screen for diffrent options.

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Ecplipse Java: using radio buttons to bring new screen for diffrent options.

    Hello, I am new to java programming. I am, currently using Eclipse to create a simple android application. In my main screen I have radio buttons which would allow the user to select the option as a radio button, i also have imported TOAST so the message appears saying which option was selected. Currently user has to select the appropriate radio button as well as press btnDisplay so the message can appear saying what was selected. All I need now is that when the user selects the radio button it would bring the appropriate XML file as well as the appropriate class for each of the radio button options depending which one was selected. I am not sure how to do that. I was thinking about array list but now I am unsure if that is what I need. Any advise would be appreciated.


  2. #2
    Forum VIP
    Join Date
    Jun 2011
    Posts
    270
    My Mood
    Bored
    Thanks
    39
    Thanked 75 Times in 63 Posts
    Blog Entries
    4

    Default Re: Ecplipse Java: using radio buttons to bring new screen for diffrent options.

    Carefully read the documentation for RadioButtons and Buttons. The android docs are designed to leave a bread crumb trail of things you need in place. In short:

    1) Set an onClick listener in the xml for the button
    android:onClick="btnDisplayClicked"
    2) Set an onClick listener in the xml for the radio buttons
    android:onClick="radioButtonItemSelected"
    3) Declare the radio button listener method in the activity. This is where you would do a switch on the Id of the radio button and set the result to a member variable.
    public void radioButtonItemSelected(View view) { }
    4) Declare the button listener in the activity. This is where you generate your toast based on the member variable.
    public void onRadioButtonClicked(View view) { }

    There are of course a lot of different ways you can go about this such as programatically defining the UI and listeners but this is the simplest to get started.

Similar Threads

  1. Button and Radio Buttons not working!!!
    By rokere1 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 19th, 2013, 03:59 PM
  2. [SOLVED] Creating Dynamically Radio Buttons, Labels
    By Onur in forum Java Theory & Questions
    Replies: 15
    Last Post: August 25th, 2011, 08:39 AM
  3. Help with radio buttons and results.
    By Bewitched1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 3rd, 2011, 03:01 PM
  4. radio buttons stop working
    By tabutcher in forum AWT / Java Swing
    Replies: 2
    Last Post: March 5th, 2010, 08:28 AM
  5. [SOLVED] Using html Radio Buttons with Servlets
    By oss_2008 in forum Java Servlet
    Replies: 2
    Last Post: June 25th, 2009, 05:39 AM