Hiding images and replacing with text when a radio button is clicked.

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Sep 9, 2015 9:06:52 AM via Website

Hi All,

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.

  • Forum posts: 26

Oct 22, 2015 4:50:47 PM via Website

the quick and dirty way to do it is have the ImageView & the TextView defined in the xml and use setVisibility to show and hide as needed.

ie: Image.setVisibility(View.GONE); // hides it completely from the layout
Text.setVisibility(View.VISIBLE); // shows the view in the layout

works on all types of views, overall its the easiest method to impliment