List of usage examples for android.widget RadioGroup setTag
public void setTag(int key, final Object tag)
From source file:it.cosenonjaviste.twowaydatabinding.DataBindingConverters.java
@BindingAdapter({ "app:binding" }) public static void bindRadioGroup(RadioGroup view, final ObservableString observableString) { if (view.getTag(R.id.bound_observable) != observableString) { view.setTag(R.id.bound_observable, observableString); view.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/* w w w .j a va 2s .co m*/ public void onCheckedChanged(RadioGroup group, int checkedId) { for (int i = 0; i < group.getChildCount(); i++) { final View child = group.getChildAt(i); if (checkedId == child.getId()) { observableString.set(child.getTag().toString()); break; } } } }); } String newValue = observableString.get(); for (int i = 0; i < view.getChildCount(); i++) { final View child = view.getChildAt(i); if (child.getTag().toString().equals(newValue)) { ((RadioButton) child).setChecked(true); break; } } }