@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_select_distinct, container, false); ((CreateGroupChannelActivity) getActivity()).setState(CreateGroupChannelActivity.STATE_SELECT_DISTINCT); mListener = (CreateGroupChannelActivity) getActivity(); mCheckBox = (CheckBox) rootView.findViewById(R.id.checkbox_select_distinct); mCheckBox.setChecked(true); mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mListener.onDistinctSelected(isChecked); } }); return rootView; }
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevents from infinite recursion if (mProtectFromCheckedChange) { return; } mProtectFromCheckedChange = true; if (mCheckedId != -1) { setCheckedStateForView(mCheckedId, false); } mProtectFromCheckedChange = false; int id = buttonView.getId(); setCheckedId(id); }
public void init() { recyclerView = (RecyclerView) findViewById(R.id.student_recyclerview); btnSearch = (ToggleButton)findViewById(R.id.btn_search_student); btnSearchOk = (Button)findViewById(R.id.btn_search_ok_student); btnBack = (Button) findViewById(R.id.btn_back_student); editTextSearch =(EditText)findViewById(R.id.etxt_search_student); frameLayoutSearch = (FrameLayout)findViewById(R.id.frame_search_student); txtMsgContent = (TextView) findViewById(R.id.message_label_stud); frameLayoutSearch.setVisibility(View.GONE); txtMsgContent.setVisibility(View.INVISIBLE); btnSearch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) frameLayoutSearch.setVisibility(View.VISIBLE); else frameLayoutSearch.setVisibility(View.GONE); } }); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { int id = buttonView.getId(); if (id == R.id.cb_origin) { if (isChecked) { long size = 0; for (ImageItem item : selectedImages) size += item.size; String fileSize = Formatter.formatFileSize(this, size); isOrigin = true; mCbOrigin.setText(getString(R.string.origin_size, fileSize)); } else { isOrigin = false; mCbOrigin.setText(getString(R.string.origin)); } } }
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(buttonView==mToggleButton) { if(isChecked){ mLastLeftSpeed=0; mLastRightSpeed = 0; mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_UI); mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_UI); } else{ mSensorManager.unregisterListener(this); setSpeed(0,0); } } }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mType = b ? MOVIES : TV_SHOWS; int textColorLight = ContextCompat.getColor(getActivity(), R.color.colorPrimary); int textColorDark = ContextCompat.getColor(getActivity(), R.color.colorGray); moviesRadioButton.setTextColor(b ? textColorLight : textColorDark); tvRadioButton.setTextColor(!b ? textColorLight : textColorDark); }
public void unSelector(int position, @NonNull RRecyclerView recyclerView, @NonNull String viewTag) { boolean notify = false; removeSelectorPosition(position); RBaseViewHolder vh = (RBaseViewHolder) recyclerView.findViewHolderForAdapterPosition(position); if (vh != null) { final View view = vh.tag(viewTag); if (view != null) { if (view instanceof CompoundButton) { checkedButton((CompoundButton) view, false); } else if (view instanceof RCheckGroup.ICheckView) { ((RCheckGroup.ICheckView) view).setChecked(false); } notify = true; } } else { notifyItemChanged(position); } if (notify) { //防止在视图还没有加载的时候,通知事件 notifySelectorChange(); } }
public RadiusViewDelegate(View view, Context context, AttributeSet attrs) { this.view = view; this.mContext = context; obtainAttributes(context, attrs); view.setSelected(selected); if (!(view instanceof CompoundButton) && !view.isClickable()) { view.setClickable(isRippleEnable); } }
private void init() { sunStrikeResources = new SunStrikeResources(getContext()); setBackgroundColor(sunStrikeResources.getColorTransparent()); setCustomColor(sunStrikeResources.getColorBackground(), sunStrikeResources.getColorProgress(), sunStrikeResources.getColorChecked()); this.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (callbackList.size() != 0) { for (Callback callback : callbackList) { if (isChecked) { callback.onChecked(); } else { callback.onUnchecked(); } } } } }); }
private void beautyView() { beautyEditText(this.mInputAccount, L10NString.getString("umgr_please_input_username"), this.mAccountTextWatcher); beautyCleanButton(this.mClearInputAccount, this); this.mInputAccountLayout.setOnClickListener(this); beautyCleanButton(this.mClearInputPassword, this); this.mInputPassword.setOnClickListener(this); beautyEditText(this.mInputPassword, L10NString.getString("umgr_please_input_password"), this.mPasswordTextWatcher); beautyColorTextView(this.mRegister, "#007dc4", false, L10NString.getString("umgr_whether_register_ornot"), this); beautyColorTextView(this.mFindpwd, "#007dc4", false, L10NString.getString("umgr_whether_forget_password"), this); beautyColorTextView(this.mSwitchAccount, "#007dc4", false, L10NString.getString("umgr_third_login_qihoo_tip"), this); beautyButtonGreen(this.mLogin, L10NString.getString("umgr_login"), this); beautyTextView(this.mAgreeClause1, L10NString.getString("umgr_login_agree_clause_1")); beautyTextView(this.mAgreeClauseUser, L10NString.getString("umgr_agree_clause_2_user")); beautyColorTextView(this.mAgreement, "#0099e5", true, L10NString.getString("umgr_agree_clause_2_agreement"), this); beautyTextView(this.mAnd, L10NString.getString("umgr_agree_clause_2_and")); beautyColorTextView(this.mPrivacy, "#0099e5", true, L10NString.getString("umgr_agree_clause_2_privacy"), this); beautyCheckButton(this.mShowPwd, new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { LoginActivity.this.mInputPassword.setTransformationMethod(LoginActivity.this.mShowPwd.isChecked() ? HideReturnsTransformationMethod.getInstance() : PasswordTransformationMethod.getInstance()); } }); loadPrivateConfig(); }
public static void checkedButton(CompoundButton compoundButton, boolean checked) { if (compoundButton == null) { return; } if (compoundButton.isChecked() == checked) { return; } CompoundButton.OnCheckedChangeListener onCheckedChangeListener = (CompoundButton.OnCheckedChangeListener) Reflect.getMember(CompoundButton.class, compoundButton, "mOnCheckedChangeListener"); compoundButton.setOnCheckedChangeListener(null); compoundButton.setChecked(checked); compoundButton.setOnCheckedChangeListener(onCheckedChangeListener); }
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_apply_on_boot, container, false); ((TextView) rootView.findViewById(R.id.title)).setText(getString(R.string.profile_tasker_toast)); SwitchCompat switchCompat = (SwitchCompat) rootView.findViewById(R.id.switcher); switchCompat.setChecked(Prefs.getBoolean("showtaskertoast", true, getActivity())); switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { Prefs.saveBoolean("showtaskertoast", b, getActivity()); } }); return rootView; }
/** * 속성 초기화, 클릭 이벤트 설정 */ private void init(Context context, int textSize) { setBackground(ContextCompat.getDrawable(context, R.drawable.dmstb)); mNormalTextColor = ContextCompat.getColor(context, R.color.colorPrimary); mCheckedTextColor = ContextCompat.getColor(context, android.R.color.white); setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked()) { setTextColor(mCheckedTextColor); } else { setTextColor(mNormalTextColor); } } }); setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityConverter.pxTodp(context, textSize)); setTextColor(mNormalTextColor); setMinWidth(0); setMinimumWidth(0); setMinHeight(0); setMinimumHeight(0); }
/** * Checkbox - Used to customize checkbox properties * For additional information please see: * https://developer.android.com/guide/topics/ui/controls/checkbox.html */ private void customizeCheckbox() { //Set the checkbox to a specific checked state checkBox.setChecked(true); //Set the label for the checkbox checkBox.setText("My Checkbox"); //Set a checked state change listener checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { Toast.makeText(getApplicationContext(), "Checkbox state changed!", Toast.LENGTH_SHORT).show(); } }); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.sw_discu_top: if (isChecked) { OperationRong.setConversationTop(mContext, Conversation.ConversationType.DISCUSSION, targetId, true); } else { OperationRong.setConversationTop(mContext, Conversation.ConversationType.DISCUSSION, targetId, false); } break; case R.id.sw_discu_notfaction: if (isChecked) { OperationRong.setConverstionNotif(mContext, Conversation.ConversationType.DISCUSSION, targetId, true); } else { OperationRong.setConverstionNotif(mContext, Conversation.ConversationType.DISCUSSION, targetId, false); } break; } }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { switch(compoundButton.getId()){ case R.id.activity_rant_checkbox_up: mDownCheckbox.setClickable(false); mUpCheckbox.setClickable(true); postThumb(1, mDetailItem.getRantId()); break; case R.id.activity_rant_checkbox_down: mDownCheckbox.setClickable(true); mUpCheckbox.setClickable(false); postThumb(-1, mDetailItem.getRantId()); break; } }
private void setBezier3View() { setContentView(R.layout.view_bezier_3); final Bezier3View bezier3View = (Bezier3View) findViewById(R.id.bezier_3_view); ((RadioButton) findViewById(R.id.control_1)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { bezier3View.setMode(isChecked); } }); /* ((RadioButton) findViewById(R.id.control_2)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { bezier3View.setMode(false); } });*/ }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { Utils.debugLog(TAG, "Received onCheckChanged(true) for Bluetooth swap, prompting user as to whether they want to enable Bluetooth."); getActivity().startBluetoothSwap(); textBluetoothVisible.setText(R.string.swap_visible_bluetooth); viewBluetoothId.setVisibility(View.VISIBLE); Utils.debugLog(TAG, "Received onCheckChanged(true) for Bluetooth swap (prompting user or setup Bluetooth complete)"); // TODO: When they deny the request for enabling bluetooth, we need to disable this switch... } else { Utils.debugLog(TAG, "Received onCheckChanged(false) for Bluetooth swap, disabling Bluetooth swap."); getManager().getBluetoothSwap().stop(); textBluetoothVisible.setText(R.string.swap_not_visible_bluetooth); viewBluetoothId.setVisibility(View.GONE); Utils.debugLog(TAG, "Received onCheckChanged(false) for Bluetooth swap, Bluetooth swap disabled successfully."); } }
@Override public void onCheckedChanged(android.widget.CompoundButton v, boolean isChecked) { int position = (Integer)v.getTag(); if(mSelected[position] != isChecked) { mSelected[position] = isChecked; if(mOnSelectionChangedListener != null) mOnSelectionChangedListener.onSelectionChanged(position, mSelected[position]); } if(mMode == MODE_ITEMS && isChecked && mLastSelectedIndex != position){ mSelected[mLastSelectedIndex] = false; if(mOnSelectionChangedListener != null) mOnSelectionChangedListener.onSelectionChanged(mLastSelectedIndex, false); CompoundButton child = (CompoundButton) mListView.getChildAt(mLastSelectedIndex - mListView.getFirstVisiblePosition()); if(child != null) child.setChecked(false); mLastSelectedIndex = position; } }
static Drawable getButtonDrawable(CompoundButton button) { if (!sButtonDrawableFieldFetched) { try { sButtonDrawableField = CompoundButton.class.getDeclaredField("mButtonDrawable"); sButtonDrawableField.setAccessible(true); } catch (NoSuchFieldException e) { Log.i(TAG, "Failed to retrieve mButtonDrawable field", e); } sButtonDrawableFieldFetched = true; } if (sButtonDrawableField != null) { try { return (Drawable) sButtonDrawableField.get(button); } catch (IllegalAccessException e2) { Log.i(TAG, "Failed to get button drawable via reflection", e2); sButtonDrawableField = null; } } return null; }
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.fragment_update_tree_details_missing_tree: mTreeIsMissing = isChecked; EditText noteTxt = (EditText) getActivity().findViewById(R.id.fragment_update_tree_details_note); if (isChecked) { noteTxt.setHint(getActivity().getResources().getString(R.string.cause_of_death)); } else { noteTxt.setHint(getActivity().getResources().getString(R.string.your_note)); } break; default: break; } }
@Override public void configViews() { noneCoverCompat.setChecked(SettingManager.getInstance().isNoneCover()); noneCoverCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SettingManager.getInstance().saveNoneCover(isChecked); } }); }
private void populate(final boolean enabled, List<DeviceActionDAO> defaultActions, List<StoryDeviceActionDAO> existingActions) { LinearLayout layout; if (enabled) { layout = findViewById(R.id.storyEnabledLinearLayout); } else { layout = findViewById(R.id.storyDisabledLinearLayout); } LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(0, 8, 0, 8); for (final DeviceActionDAO action : defaultActions) { Switch s = new Switch(this); s.setText(action.getName()); s.setLayoutParams(lp); // Check the matching switch for every list for (StoryDeviceActionDAO existingAction : existingActions) { if (enabled && existingAction.isEnabled() && existingAction.getActionId() == action.getId()) { s.setChecked(true); break; } else if (!enabled && !existingAction.isEnabled() && existingAction.getActionId() == action.getId()) { s.setChecked(true); break; } } layout.addView(s); s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { if (checked) { db.createActionForStoryAndDevice(storyId, enabled, action); } else { db.deleteActionForStoryAndDevice(storyId, enabled, action); } } }); } }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ReportField field = (ReportField) buttonView.getTag(); if (field != null) { if (isChecked) excludedFields.remove(field); else excludedFields.add(field); } }
private void initView(Context context) { mContext = context; LayoutInflater.from(context).inflate(R.layout.card_monitor_setting, this); onlyTextRL = (RelativeLayout) findViewById(R.id.text_only_rl); onlyTextSwitch = (SwitchCompat) findViewById(R.id.text_only_switch); whiteList = (TextView) findViewById(R.id.white_list); doubleClickIntervalRl = (RelativeLayout) findViewById(R.id.double_click_interval_rl); mDoubleClick = (TextView) findViewById(R.id.double_click_setting); doubleClickEditText = (EditText) findViewById(R.id.double_click_interval_edit); doubleClickInputLayout = (TextInputLayout) findViewById(R.id.double_click_interval); doubleClickConfirm = (Button) findViewById(R.id.double_click_confirm); onlyTextSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton aSwitch, boolean isChecked) { //这里由于文案从“只监控文本”改成了“增强型监控”,所以意思完全相反了,为了防止改动太多,就在这里做一个反置 onlyText = !isChecked; UrlCountUtil.onEvent(UrlCountUtil.STATUS_ONLY_TEXT_MONITOR, !isChecked); SPHelper.save(ConstantUtil.TEXT_ONLY, onlyText); mContext.sendBroadcast(new Intent(BROADCAST_BIGBANG_MONITOR_SERVICE_MODIFIED)); } }); onlyTextRL.setOnClickListener(myOnClickListerner); whiteList.setOnClickListener(myOnClickListerner); mDoubleClick.setOnClickListener(myOnClickListerner); doubleClickConfirm.setOnClickListener(myOnClickListerner); refresh(); }
private RadioButton newRadioButton(Condition condition) { final RadioButton button = new RadioButton(mContext); button.setTag(condition); button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { setCondition((Condition) button.getTag()); } } }); addView(button); return button; }
/** * Called when checking the client certificate CheckBox */ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { updateViewVisibility(isChecked); validateFields(); // Have the user select (or confirm) the client certificate if (isChecked) { mClientCertificateSpinner.chooseCertificate(); } }
/** * Determines where to position dividers between children. Note: this is an 'illegal' override * of a hidden method. * * @param childIndex Index of child to check for preceding divider * @return true if there should be a divider before the child at childIndex */ protected boolean hasDividerBeforeChildAt(int childIndex) { final CompoundButton child = (CompoundButton) getChildAt(childIndex); if (child == null) return false; if (child.getVisibility() == GONE) return false; final CompoundButton previous = getVisibleViewBeforeChildAt(childIndex); if (previous == null) return false; // If both are checked, add a divider return child.isChecked() && previous.isChecked(); }
@Override public void setCheckedChangeListener(final IOnCheckedChangeListener<ExampleViewHolder, Long> listener) { mRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { listener.onCheckedChange(ExampleViewHolder.this, buttonView, isChecked); } }); }
private void setListener() { cbLaws.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { etPsw.setInputType(InputType.TYPE_CLASS_TEXT| InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { etPsw.setInputType(InputType.TYPE_CLASS_TEXT| InputType.TYPE_TEXT_VARIATION_PASSWORD); } } }); }
public void onCheckedChanged(CompoundButton v, boolean isChecked) { switch (v.getId()) { case R.id.ckShowAllAirports: setShowAllAirports(v.isChecked()); break; default: break; } }
private void setShowNotifs(Switch toggle) { toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { activity.setThings.editor.putBoolean("showNotifs", true); showNotifs = "true"; } else { activity.setThings.editor.putBoolean("showNotifs", false); showNotifs = "false"; } activity.setThings.editor.apply(); } }); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { btnRandomColor.setVisibility(View.GONE); flActivityContainer.setBackgroundResource(R.drawable.bg_bar); } else { btnRandomColor.setVisibility(View.VISIBLE); flActivityContainer.setBackgroundColor(Color.WHITE); } updateStatusBar(); }
private void iniOfflineSwitch() { getOfflineSwitcher().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { preferenceUtils.writeLogic(PreferenceUtils.OFFLINE_MODE, b); finish(); } }); }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { realm.executeTransaction(r -> { studyItem.setCompleted(isChecked); day.updateDateCompleted(); } ); listener.onItemChecked(); }
public void setAudioMuteButtonListener(final MuteButtonListener listener) { audioMuteButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { listener.onToggle(b); } }); }
private void setupPlayPauseToggleButton() { if (mPlayPauseToggleButton == null) { return; } mPlayPauseToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mAnimatedDrawable.start(); } else { mAnimatedDrawable.stop(); } } }); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { super.onCheckedChanged(buttonView, isChecked); if (buttonView == mToggleHeader) { adjustPageHeaderAndFooter(mPageScrollView.getOrientation() == PageScrollView.VERTICAL, true, isChecked); } if (buttonView == mToggleFooter) { adjustPageHeaderAndFooter(mPageScrollView.getOrientation() == PageScrollView.VERTICAL, false, isChecked); } }
private void initNavView(){ MenuItem item = mNavigationView.getMenu().findItem(R.id.nav_theme); mNavigationView.getMenu().findItem(R.id.nav_home).setChecked(true); mThemeSwitch = (SwitchCompat) MenuItemCompat .getActionView(item) .findViewById(R.id.theme_switch); // mThemeSwitch.setChecked(!SkinPreUtils.getInstance(this).getSkinPath().equals("")); mThemeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ /* * 这里有待改进,是读取apk包的地方 * */ String skinPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "skin_night.apk"; mSkinManager.loadSkin(skinPath); }else{ mSkinManager.restoreDefault(); } } }); }