在Android中隐藏RadioButton [英] Hiding a RadioButton in Android

查看:804
本文介绍了在Android中隐藏RadioButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将RadioButton的可见性设置为INVISIBLE或GONE.由于某些原因,这无法正常工作.

I want to set the visibility of a RadioButton to INVISIBLE or GONE. For some reason this isn't working.

RadioButton myRadioButton = (RadioButton) findViewById(R.id.my_radio_button_id);
myRadioButton.setVisibility(View.GONE);

myRadioButton.setVisibility(View.INVISIBLE);

没有错误返回,它什么都不做.

No error is returned, it just doesn't do anything.

但是我在RadioGroup上尝试过

However I have tried this on the RadioGroup

RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.radiogroup_quiz_answers);
myRadioGroup.setVisibility(View.INVISIBLE);

可以很好地隐藏整个群组.有没有办法只隐藏其中一个RadioButtons?我有3人一组,可以回答问题,但在某些情况下,我想隐藏最后一个.

And it works fine to hide the whole group. Is there a way to just hide one of the RadioButtons? I have a group of 3 which are answers to questions but in some cases I want to hide the last one.

推荐答案

您可以通过这种方式隐藏特定的单选按钮

you can hide the particular radio button this way

RadioButton myRadioButton = (RadioButton) findViewById(R.id.last_radio);
myRadioButton.setVisibility(View.INVISIBLE);

或者如果您使用查看已消失" menas单选按钮,则将其隐藏在空白处

or if you use View Gone menas radio button hide with sapce

RadioButton myRadioButton = (RadioButton) findViewById(R.id.last_radio);
myRadioButton.setVisibility(View.GONE);

在这种情况下,请不要隐藏广播组

In that case do not hide the radio group

RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.radiogroup_quiz_answers);
myRadioGroup.setVisibility(View.Visible);

这篇关于在Android中隐藏RadioButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆