/** * {@inheritDoc} */ @Override public void onChildViewRemoved(View parent, View child) { if (parent == RadioGridGroup.this && child instanceof RadioButton) { ((RadioButton) child).setOnCheckedChangeListener(null); } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } }
private void changeButtonStatus(int index, boolean check){ RadioButton button; switch (index){ case PAGE_COMMON: button = mCommon; break; case PAGE_TRANSLUCENT: button = mTranslucent; break; case PAGE_COORDINATOR: button = mCoordinator; break; case PAGE_COLLAPSING_TOOLBAR: button = mCollapsingToolbar; break; default: button = mCommon; } button.setOnCheckedChangeListener(null); button.setChecked(check); button.setOnCheckedChangeListener(this); if (check) { button.setTextColor(ContextCompat.getColor(this, R.color.colorAccent)); } else { button.setTextColor(ContextCompat.getColor(this, R.color.colorBlack)); } }
/** * {@inheritDoc} */ @Override public void onChildViewAdded(View parent, View child) { if (parent == RadioGridGroup.this && child instanceof RadioButton) { int id = child.getId(); // generates an id if it's missing if (id == View.NO_ID) { id = ViewUtils.generateViewId(); child.setId(id); } ((RadioButton) child).setOnCheckedChangeListener( mChildOnCheckedChangeListener); } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewAdded(parent, child); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(null); setContentView(R.layout.activity_main); fragments.put(PAGE_COMMON, new CommonFragment()); fragments.put(PAGE_TRANSLUCENT, new TranslucentFragment()); fragments.put(PAGE_COORDINATOR, new DrawerFragment()); fragments.put(PAGE_COLLAPSING_TOOLBAR, new CollapsingToolbarFragment()); mCommon = (RadioButton) findViewById(R.id.common); mCommon.setOnCheckedChangeListener(this); mTranslucent = (RadioButton) findViewById(R.id.translucent); mTranslucent.setOnCheckedChangeListener(this); mCoordinator = (RadioButton) findViewById(R.id.coordinator); mCoordinator.setOnCheckedChangeListener(this); mCollapsingToolbar = (RadioButton) findViewById(R.id.collapsing_toolbar); mCollapsingToolbar.setOnCheckedChangeListener(this); FragmentTransaction ft = MainActivity.this.getSupportFragmentManager().beginTransaction(); ft.add(fragmentContentId, fragments.get(PAGE_COMMON)); currentTab = PAGE_COMMON; mCommon.setTextColor(getResources().getColor(R.color.colorAccent)); ft.commit(); }
radioButton1.setOnCheckedChangeListener(radioCheckChangeListener); radioButton2.setOnCheckedChangeListener(radioCheckChangeListener); radioButton3.setOnCheckedChangeListener(radioCheckChangeListener);
wepRB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b){
private void initView() { rb_tab1 = (RadioButton) this.findViewById(R.id.rb_tab1); rb_tab2 = (RadioButton) this.findViewById(R.id.rb_tab2); rb_tab3 = (RadioButton) this.findViewById(R.id.rb_tab3); rb_tab1.setOnCheckedChangeListener(this); rb_tab2.setOnCheckedChangeListener(this); rb_tab3.setOnCheckedChangeListener(this); }
/** * {@inheritDoc} */ public void onChildViewRemoved(View parent, View child) { if (parent == RelativeRadioGroup.this && child instanceof RadioButton) { ((RadioButton) child).setOnCheckedChangeListener(null); // setOnCheckedChangeWidgetListener(null); } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } }
public void onChildViewRemoved(View parent, View child) { if (parent == KeyRadioGroupV1.this) { List<RadioButton> allRadioButton = getAllRadioButton(child); if(allRadioButton != null && allRadioButton.size() > 0){ for(RadioButton button : allRadioButton){ button.setOnCheckedChangeListener(null); } } } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } }
private void setViews(View root) { RadioGroup imageRg = root.findViewById(R.id.image_rg); imageRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Toast.makeText(getActivity(), "checked", Toast.LENGTH_SHORT).show(); } }); // FIXME: 2018/4/25 這裏有個bug是必須在代碼中設置默認的選中狀態 ((RadioButton) imageRg.getChildAt(0)).setChecked(true); ((RadioButton) imageRg.getChildAt(0)).setOnCheckedChangeListener(this); ((RadioButton) imageRg.getChildAt(1)).setOnCheckedChangeListener(this); ((RadioButton) imageRg.getChildAt(2)).setOnCheckedChangeListener(this); }
/** * 移除同上 */ public void onChildViewRemoved(View parent, View child) { if (parent == KeyRadioGroupV2.this && child instanceof ViewGroup) { int childCount = ((ViewGroup) child).getChildCount(); for (int i = 0; i < childCount; i++) { ((RadioButton) ((ViewGroup) child).getChildAt(i)).setOnCheckedChangeListener(null); } } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } }
/** * {@inheritDoc} */ public void onChildViewRemoved(View parent, View child) { if (parent == MultiRadioGroup.this) { List<RadioButton> buttons = getAllRadioButton(child); if(buttons != null && buttons.size() > 0){ for(RadioButton button : buttons){ button.setOnCheckedChangeListener(null); } } } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } }
/** * {@inheritDoc} */ public void onChildViewRemoved(View parent, View child) { if (parent == XmRadioGroup.this && child instanceof RadioButton) { ((RadioButton) child).setOnCheckedChangeListener(null); } else if (parent == XmRadioGroup.this && child instanceof ViewGroup) { RadioButton btn = findRadioButton((ViewGroup) child); if (btn != null) btn.setOnCheckedChangeListener(null); } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewRemoved(parent, child); } } }
private OnCheckedChangeListener checkListener = new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { for (int i = 0; i < count; i++) { if (buttonView.getId() == 5000 + i) { Log.e("XXX", "Position " + i); } else { RadioButton rb = (RadioButton) findViewById((5000 + i)); rb.setOnCheckedChangeListener(null); rb.setChecked(false); rb.setOnCheckedChangeListener(checkListener); } } } };
public static void setUpRadioButton(Dialog dialog, @IdRes int checkBoxId, final IChartModifier modifier) { final RadioButton radioButton = (RadioButton) dialog.findViewById(checkBoxId); radioButton.setChecked(modifier.getIsEnabled()); radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { modifier.setIsEnabled(isChecked); } }); }
private void initializeRadioButtons() { ((RadioButton) getActivity().findViewById(R.id.rollover)).setOnCheckedChangeListener(new RadioButtonCheckedChangeListener(rolloverModifier)); ((RadioButton) getActivity().findViewById(R.id.cursor)).setOnCheckedChangeListener(new RadioButtonCheckedChangeListener(cursorModifier)); ((RadioButton) getActivity().findViewById(R.id.tooltip)).setOnCheckedChangeListener(new RadioButtonCheckedChangeListener(tooltipModifier)); }
/** * {@inheritDoc} */ public void onChildViewAdded(View parent, View child) { if (parent == RelativeRadioGroup.this && child instanceof RadioButton) { int id = child.getId(); // generates an id if it's missing if (id == View.NO_ID) { id = child.hashCode(); child.setId(id); } ((RadioButton) child).setOnCheckedChangeListener( // setOnCheckedChangeWidgetListener( mChildOnCheckedChangeListener); } if (mOnHierarchyChangeListener != null) { mOnHierarchyChangeListener.onChildViewAdded(parent, child); } }
@BindingAdapter({"checked", "model"}) public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) { if (checked == null) { return; } radioButton.setOnCheckedChangeListener( (buttonView, isChecked) -> { if ((checked.get() == null || !checked.get().equals(model)) && isChecked) { checked.set(model); } }); final T checkedModel = checked.get(); final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model); if (shouldBeChecked != radioButton.isChecked()) { radioButton.setChecked(shouldBeChecked); } }
private RadioButton makeRadioButton(RadioGroup baks, final String bk, final boolean item) { RadioButton bkb = new RadioButton(this); bkb.setText(bk); bkb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { selectedBackup = bk; selected = item; Log.d("backuppage", "selected = " + selectedBackup); backupSelected(selected); } } }); baks.addView(bkb); return bkb; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setup); ((SpeculumApplication) getApplication()).createSetupComponent(this).inject(this); ButterKnife.bind(this); Assent.setActivity(this, this); if (!Assent.isPermissionGranted(Assent.READ_CALENDAR)) { Assent.requestPermissions(result -> { // Permission granted or denied if (!result.allPermissionsGranted()) { Toast.makeText(SetupActivity.this, noPermissionForCalendar, Toast.LENGTH_SHORT).show(); } }, 1, Assent.READ_CALENDAR); } cbVoiceCommands.setOnCheckedChangeListener(this); rbSimpleLayout.setOnCheckedChangeListener(this); }