單選按鈕,如果我有7個單選按鈕一個RadioGroup中,我希望他們要對齊這樣的:如何安排一定的方式
button2 button5
button1 button3 button6
button4 button7
有沒有一種方法可以讓我做上面的一個RadioGroup中(我我確定甚至Button1的是在第一線,但是這是我要尋找的總體佈局)
請幫
感謝
單選按鈕,如果我有7個單選按鈕一個RadioGroup中,我希望他們要對齊這樣的:如何安排一定的方式
button2 button5
button1 button3 button6
button4 button7
有沒有一種方法可以讓我做上面的一個RadioGroup中(我我確定甚至Button1的是在第一線,但是這是我要尋找的總體佈局)
請幫
感謝
你可以實現自己的按鈕操作日誌IC,在此基礎上http://developer.android.com/reference/android/widget/RadioGroup.OnCheckedChangeListener.html:
public class RadioButtonHandler implements RadioButton.OnCheckedChangeListener {
private CompoundButton currentlyCheckedButton = null;
public void onCheckedChanged(CompoundButton button, boolean isChecked) {
if (isChecked) {
currentlyCheckedButton .setChecked(false);
currentlyCheckedButton = button;
}
}
public void addButton(RadioButton button) {
// if this is the first button, set it as the current button
if (currentlyCheckedButton == null) {
currentlyCheckedButton = button;
}
button.setOnCheckedChangeListener(this);
}
public CompoundButton getCheckedRadioButton() {
return currentlyCheckedButton ;
}
}
實例化這個類並調用Add按鈕每個按鈕該類應該控制。然後,您可以將按鈕佈置在所需的任何視圖組中。向onCheckChanged回調中添加額外的邏輯或調用getCheckedRadioButton,它將返回對當前選中按鈕的引用。
[編輯]修正錯字= getCheckedButton? - > getCheckedRadioButton
沒有回答還建議? – Snake
RelativeLayout將dp – Simon
如何使用ONE radio組的相對佈局? – Snake