我想將RadioButton的可見性設置爲INVISIBLE或GONE。由於某種原因,這是行不通的。在Android中隱藏RadioButton
RadioButton myRadioButton = (RadioButton) findViewById(R.id.my_radio_button_id);
myRadioButton.setVisibility(View.GONE);
或
myRadioButton.setVisibility(View.INVISIBLE);
沒有錯誤返回,它只是沒有做任何事情。
但是我已經試過這在RadioGroup中
RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.radiogroup_quiz_answers);
myRadioGroup.setVisibility(View.INVISIBLE);
,它工作正常隱藏整個集團。有沒有辦法隱藏其中一個RadioButton?我有一組3個問題的答案,但在某些情況下,我想隱藏最後一個問題。
這是行不通的,howe ver以上面的格式(我用編程方式將它隱藏在onCreate方法中),但它沒有。不幸的是,在點擊時隱藏它並不能幫助我解決這種情況。 –
@MarkWinterbottom看到我編輯的答案,你可以在XML本身。 – Nirmal