I have an onCheckChangedListener to show a textView depending on which radio button is selected. I have 1 question and 1 problem that I was wondering if anyone could help me wi
The View
class includes a getVisibility() method. Compare that:
Eg:
if (TvFolk1.getVisibility() == View.VISIBLE)
TvFolk2.setVisibility(View.GONE);
To shorten down code, you can also make a method:
public static void goneIfVisible (View v)
{
if (v.getVisibility() == View.VISIBLE)
v.setVisibility(View.GONE);
}
And keep in mind in Java, variables are lowercased, only use uppercase for class names.
// If TextView is already showing and you want to hide it.
if (TvFolk1.isShown()) {
TvFolk2.setVisibility(View.INVISIBLE);
}
// For uncheck all radio button from radio button groups
RadioGroup rgButton = (RadioGroup)findViewById(R.id.radiobuttongroup);
rgButton.clearCheck();