Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Replacing images with text when a radio button is clicked.

    • 1
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 241
    Answer it

    I am a newbie developer to android. I am trying to develop an application as a test run it is a Q and A app.

    Can anyone help me with the following problem.

    The pages have 2 radio buttons in a radio group, the center of the page has an image, and a few buttons(Next, Previous, Home) at the bottom. The part I need help with is when a user clicks on a radio button the image needs to disappear and the answer (Text) needs to appear in a scroll text box. The app is Yes/No based so when either button is clicked the image need to disappear and text needs to replace it.

    Thank you in advance.

 1 Answer(s)

  • First you need to implement onCheckedChange listener on the radio group from which you can identify which radio button is clicked. Implement listener like this:-

    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.yourRadioGroup);        
        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() 
        {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                // checkedId is the RadioButton selected
            }
        });
    

    Now you know which radio button is checked or selected. After this simply hide the image and show the test using setVisibility method of View class.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: