我有两个RadioButtons
在同一个RadioGroup
里面。但除了每个RadioButton
之外,我还需要一个ImageButton
(信息)。因此,我的代码如下:
<RadioGroup>
<LinearLayout> //Horizontal
<RadioButton/>
<ImageButton/>
</LinearLayout>
<LinearLayout> //Horizontal
<RadioButton/>
<ImageButton/>
</LinearLayout>
<RadioGroup/>
但现在我面临的问题相当简单,两个单选按钮都可以选择。我一次只想选一个。
请忽略任何打字错误。一定要从电话里发这个。
最佳答案
RadioGroup
s本身就是LinearLayout
s,仅作为直接子女支持RadioButton
s。您可以看到这种行为here。
你要做的是不可能的,因为你把你的RadioButton
包装在一个LinearLayout
里。
您有两种可能:您可以复制代码并创建自己的RadioGroup
,
或者您可以extend RadioButton
并通过在RadioButton
中应用自定义布局来改变它的外观。