【发布时间】:2015-11-21 16:55:54
【问题描述】:
我有一个 RadioGroup
<RadioGroup
android:id="@+id/typeGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/type0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="type0" />
<RadioButton
android:id="@+id/type1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="type1" />
</RadioGroup>
这是程序,我可以要求用户确认更改,如果没有,单选按钮不应该更改,是否有javascript的preventDefault之类的功能?
typeGroup=(RadioGroup)findViewById(R.id.typeGroup);
typeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
type=group.indexOfChild((RadioButton) findViewById(checkedId));
//dialog confirm change
//if yes, keep going
//if no, stop event
}
}
);
【问题讨论】:
标签: java android radio-button android-radiogroup