how can i set visibility property of radiobutton

天大地大妈咪最大 提交于 2019-12-11 22:11:11

问题


I have problem with RadioButton in xamarin. I would like to make my RadioButtons visible but I don't know how to do this. My RadioButtons are invisible in my xml file. I would like to make them visible from code. I need this because I want to make a list of the last logon users and when I choose one he fill my boxes. But on start I dont have 3 users but only 1 so I need to hide not used RadioButtons. So how can I change property of my RadioButtons?


回答1:


To make a radio button visible:

radioButton.setVisibility(View.VISIBLE);

To make a radio button invisible:

radioButton.setVisibility(View.GONE);

This works fine presuming you have correctly initialized radioButton in Activity.

For Xamarin.Android C# try this:

button.Visibility = ViewStates.Invisible;

Reference link 1 and Reference link 2




回答2:


Try this code:

RadioButton rb = (RadioButton) findViewById(R.id.firstRadio);
rb.setVisibility(View.VISIBLE);



回答3:


This is kind of a pain sometimes, because sometimes you have to dig a little bit deaper, since it does not always work 100%, but the Basic in Xamarin/C# to use is as follow:

rb.Visibility=ViewStates.Visible;



来源:https://stackoverflow.com/questions/24532839/how-can-i-set-visibility-property-of-radiobutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!