@Override public void onClick(View convertView) { LogHelper.d("test", "test item clicked: "); ViewHolder holder = (ViewHolder) convertView.getTag(); CompoundButton b = holder.cbFilter; b.setChecked(!b.isChecked()); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!buttonView.isPressed()) { return; } if (!isChecked) { // If it got unchecked, we don't care. return; } for (RadioButton button : this.buttons) { if (button.isChecked() && !(buttonView == button)) { button.setChecked(false); } } Collect.getInstance() .getActivityLogger() .logInstanceAction( this, "onCheckedChanged", mItems.get((Integer) buttonView.getTag()).getValue(), mPrompt.getIndex()); listener.advance(); }
private void updateDoneButtonState() { if (mModel.recurrenceState == RecurrenceModel.STATE_NO_RECURRENCE) { mDoneButton.setEnabled(true); return; } if (mInterval.getText().toString().length() == 0) { mDoneButton.setEnabled(false); return; } if (mEndCount.getVisibility() == View.VISIBLE && mEndCount.getText().toString().length() == 0) { mDoneButton.setEnabled(false); return; } if (mModel.freq == RecurrenceModel.FREQ_WEEKLY) { for (CompoundButton b : mWeekByDayButtons) { if (b.isChecked()) { mDoneButton.setEnabled(true); return; } } mDoneButton.setEnabled(false); return; } mDoneButton.setEnabled(true); }
public void setChecked(boolean checked) { _isChecked = checked; if (encapsulated != null) { CompoundButton cb = (CompoundButton) encapsulated; cb.setChecked(_isChecked); } }
public MQuery checked(boolean checked) { if (view instanceof CompoundButton) { CompoundButton cb = (CompoundButton) view; cb.setChecked(checked); } return this; }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.scan_toggle_button: if (isChecked) { buttonView.setChecked(true); buttonView.setBackgroundColor(Color.parseColor("#FF0505")); // red mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener( this, mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE), SensorManager.SENSOR_DELAY_FASTEST); } else { buttonView.setChecked(false); buttonView.setBackgroundColor(Color.parseColor("#259C25")); // greed mSensorManager.unregisterListener(this); // Serialization.serExternalData(Serialization.DATA_FILE, sensorData); if (!isRestarted) { showInputDialog(); isRestarted = false; } } break; default: Log.e("Error", "Toggle Button not found!"); } }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (!b) { compoundButton.setTextColor(getResources().getColor(R.color.blue_sky)); } else { compoundButton.setTextColor(getResources().getColor(R.color.white)); } }
public boolean isChecked() { boolean checked = false; if (view instanceof CompoundButton) { CompoundButton cb = (CompoundButton) view; checked = cb.isChecked(); } return checked; }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) overlay[Integer.parseInt(buttonView.getTag().toString())].setVisibility(View.VISIBLE); else overlay[Integer.parseInt(buttonView.getTag().toString())].setVisibility(View.INVISIBLE); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { Log.i("复选按钮", "选中了[" + buttonView.getText().toString() + "]"); } else { Log.i("复选按钮", "取消了[" + buttonView.getText().toString() + "]"); } }
@Override public void onClick(View v) { CompoundButton compoundButton = (CompoundButton) v; if (compoundButton.isChecked()) { compoundButton.startAnimation(tl_preview_show); } else { compoundButton.startAnimation(tl_preview_hide); } }
@Test public void testCompoundButtonPassedToAnnotatedMethod() { assertThat(activity.button).isNull(); CompoundButton button = (CompoundButton) activity.findViewById(R.id.conventionButton); button.setChecked(true); assertThat(button).isEqualTo(activity.button); }
public void setJavascriptEnabled(boolean jsEnabled) { Log.d(L.TAG, "Control bar: Javascript " + (jsEnabled ? "enabled" : "disabled")); if (jsToggle.isChecked() != jsEnabled) { jsToggle.setOnCheckedChangeListener(null); jsToggle.setChecked(jsEnabled); jsToggle.setOnCheckedChangeListener(this); } jsToggle.setEnabled(true); }
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (buttonView.getId() == R.id.radioButtonPoint) { rZone.setChecked(false); } if (buttonView.getId() == R.id.radioButtonZone) { rPoint.setChecked(false); } } }
private void applyView(String providerNameText, boolean switchOn, String secondRowText) { mProviderName.setText(providerNameText); if (mSignInSwitch != null && (!mUserChanged)) { mSignInSwitch.setOnCheckedChangeListener(null); mSignInSwitch.setChecked(switchOn); mSignInSwitch.setOnCheckedChangeListener(mCheckedChangeListner); } if (mLoginName != null) mLoginName.setText(secondRowText); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { tags.add(buttonView.getText().toString()); checkSubmitOk(); } else { tags.remove(buttonView.getText().toString()); if (tags.size() == 0) { checkSubmitOk(); } } }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { expandFocusResultChange(buttonView.getText().toString()); Object o = buttonView.getTag(); if (o instanceof AccountsModel) { account = (AccountsModel) buttonView.getTag(); } } }
private void createButtons() { button_fullscreen = (ToggleButton) findViewById(R.id.MSWMfullscreen); button_fullscreen.setOnClickListener(this); button_playpause = (ToggleButton) findViewById(R.id.MSWMplaypause); button_playpause.setOnClickListener(this); button_rewind = (Button) findViewById(R.id.MSWMrewind); button_rewind.setOnClickListener( new OnClickListener() { public void onClick(View v) { new runCmd().execute(Consts.VIDEO_SKIP_BACKWARDS, ""); } }); button_foward = (Button) findViewById(R.id.MSWMfoward); button_foward.setOnClickListener( new OnClickListener() { public void onClick(View v) { new runCmd().execute(Consts.VIDEO_SKIP_FOWARD, ""); } }); button_stop = (Button) findViewById(R.id.MSWMstop); button_stop.setOnClickListener( new OnClickListener() { public void onClick(View v) { new runCmd().execute(Consts.VIDEO_STOP, ""); CompoundButton btn = (ToggleButton) findViewById(R.id.MSWMfullscreen); if (btn.isChecked()) { btn.setChecked(false); } btn = (ToggleButton) findViewById(R.id.MSWMplaypause); if (btn.isChecked()) { btn.setChecked(false); } } }); button_mute = (Button) findViewById(R.id.MSWMmute); button_mute.setOnClickListener( new OnClickListener() { public void onClick(View v) { new runCmd().execute(Consts.VIDEO_MUTE, ""); } }); button_quit = (Button) findViewById(R.id.MSWMquit); button_quit.setOnClickListener( new OnClickListener() { public void onClick(View v) { new runCmd().execute(Consts.VIDEO_QUIT, ""); quit(false); } }); set_sizes(); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { // 龙城太原 case R.id.main_footbar_lcty: // 改变按钮状态 if (buttonView.isChecked()) { radioButton_wzty.setChecked(false); radioButton_xzty.setChecked(false); // 改变标题 title.setText(R.string.mian_lcty); // 设置主图标显示的适配器 gridView.setAdapter(adapter_lcty); } break; // 玩在太原 case R.id.main_footbar_wzty: if (buttonView.isChecked()) { radioButton_lcty.setChecked(false); radioButton_xzty.setChecked(false); title.setText(R.string.mian_wzty); gridView.setAdapter(adapter_wzty); } break; // 学在太原 case R.id.main_footbar_xzty: if (buttonView.isChecked()) { radioButton_lcty.setChecked(false); radioButton_wzty.setChecked(false); title.setText(R.string.mian_xzty); gridView.setAdapter(adapter_xzty); } break; // 摇我喜欢 case R.id.main_footbar_shake_i_like: // 改变按钮状态 if (buttonView.isChecked()) { radioButton_shak_i_like.setChecked(false); // 防止回退时是按下状态 Intent intent = new Intent(MainActivity.this, ShakeILikeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.hold); // 淡入 } break; default: break; } }
/** @see CompoundButton#setButtonDrawable(int) */ private void checkCompoundButton(Context context, AttributeSet attrs, View view) { if (view instanceof CompoundButton) { CompoundButton button = (CompoundButton) view; final TypedValue value = new TypedValue(); TypedArray array = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.CompoundButton, 0, 0); array.getValue(com.android.internal.R.styleable.CompoundButton_button, value); EnvRes buttonRes = new EnvRes(value.resourceId); if (buttonRes.isValid()) { button.setButtonDrawable(buttonRes.getResid()); } array.recycle(); } }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.checkBox_toggleService: toggleService(isChecked); break; case R.id.checkBox_toggleSafetyLevel: toggleSafety(isChecked); break; case R.id.checkBox_VolumeButtonHack: toggleVolumeButtonHack(isChecked); break; case R.id.checkBox_musicHack: spe.putBoolean(CHECKBOX_MUSIC_HACK, isChecked); while (!spe.commit()) {} break; case R.id.checkBox_voiceCallHack: spe.putBoolean(CHECKBOX_VOICE_CALL_HACK, isChecked); while (!spe.commit()) {} break; case R.id.checkBox_ringHack: spe.putBoolean(CHECKBOX_RING_HACK, isChecked); while (!spe.commit()) {} break; } }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { // If it got unchecked, we don't care. return; } for (RadioButton button : buttons) { if (button.isChecked() && !(buttonView == button)) { button.setChecked(false); } } SelectChoice choice = mItems.get((Integer) buttonView.getTag()); if (choice != null) { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "onCheckedChanged", choice.getValue(), mPrompt.getIndex()); } else { Collect.getInstance() .getActivityLogger() .logInstanceAction(this, "onCheckedChanged", "<no matching choice>", mPrompt.getIndex()); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // calculate the left and right values float right = this.getWidth() - this.getPaddingRight(); float left = right - this.getWidth() + this.getPaddingLeft(); float height = this.getHeight() - this.getPaddingTop() - this.getPaddingBottom(); float radius = height / 2; // 圓半徑 oval.set(left, 0, right, height); if (this.isChecked()) { paint.setColor(Color.parseColor("#4B96C2")); // paint.setColor(Color.parseColor("#5a7fc0")); canvas.drawRoundRect(oval, radius, radius, paint); paint.setColor(Color.WHITE); canvas.drawCircle(right - radius, radius, radius - SWITCH_BOUND, paint); } else { paint.setColor(Color.GRAY); canvas.drawRoundRect(oval, radius, radius, paint); paint.setColor(Color.WHITE); canvas.drawCircle(left + radius, radius, radius - SWITCH_BOUND, paint); } canvas.save(); }
/** * 清空单选按钮 * * @param buttonView */ private void clearRadio(CompoundButton buttonView) { for (RadioButton radio : radioBtns) { if (radio.isChecked() && radio.getId() != buttonView.getId()) { radio.setChecked(false); } } }
// 벨소리 모드 설정의 토글버튼 체크값이 바뀌었을때 호출된다. @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mStateEvent) return; // 이중 호출 방지용이다. mStateEvent = true; // 모두 OFF로 초기화시켜 놓고! mute.setChecked(false); ring.setChecked(false); vibrate.setChecked(false); // ID값을 검사해서 해당되는 놈만 ON시켜준다. switch (buttonView.getId()) { case R.id.mute: mute.setChecked(true); break; case R.id.vibrate: vibrate.setChecked(true); break; case R.id.ring: ring.setChecked(true); } mStateEvent = false; }
@Override public void setBackgroundDrawable(Drawable drawable) { Drawable background = getBackground(); if (background instanceof RippleDrawable && !(drawable instanceof RippleDrawable)) ((RippleDrawable) background).setBackgroundDrawable(drawable); else super.setBackgroundDrawable(drawable); }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { sparseBooleanArray.put((Integer) compoundButton.getTag(), b); LinearLayout ll = (LinearLayout) compoundButton.getParent(); int[] diems = getDims(ll); if (b) { this.callback.itemSelected(sparseBooleanArray); ll.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.list_pressed_holo_light)); ll.setPadding(diems[0], diems[1], diems[2], diems[3]); } else { this.callback.itemDeSelected(sparseBooleanArray); ll.setBackgroundDrawable(null); ll.setPadding(diems[0], diems[1], diems[2], diems[3]); } }
@Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { final Item item = (Item) buttonView.getTag(); RelativeLayout viewLayout = (RelativeLayout) buttonView.getParent().getParent(); TextView itemContent = (TextView) viewLayout.findViewById(R.id.item_list_item_content); if (isChecked) { itemContent.setTextColor(Color.GRAY); } else { itemContent.setTextColor((0xFF << 24) | item.getItemPriorityColor()); } if (mOnItemCompleted != null) { mOnItemCompleted.onItemCompleted(item, isChecked); } }
@Override protected void onFinishInflate() { super.onFinishInflate(); title = (TextView) findViewById(R.id.title); controlPad = (ViewGroup) findViewById(R.id.controlPad); progress = (ProgressBar) findViewById(R.id.progress); jsToggle = (CompoundButton) this.controlPad.findViewById(R.id.jsToggle); jsToggle.setOnCheckedChangeListener(this); // Control pad animations pullPad = AnimationUtils.loadAnimation(getContext(), R.anim.pull_control_pad); pushPad = AnimationUtils.loadAnimation(getContext(), R.anim.push_control_pad); pushPad.setAnimationListener( new AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationRepeat(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { setVisibility(View.INVISIBLE); setTitle(null); } }); }
private void updateUI() { LockMediator lm = LockMediator.getInstance(getActivity()); boolean isActive = dpm.isAdminActive(cn); disabledWarning.setVisibility(isActive ? View.GONE : View.VISIBLE); passwordWarning.setVisibility( CryptoUtils.isPasswordSaved(getActivity()) ? View.GONE : View.VISIBLE); warning.setVisibility(isActive && areOtherAdminsSet() ? View.VISIBLE : View.GONE); toggle.setChecked(isActive); if (!CryptoUtils.isPasswordSaved(getActivity())) { pinPasswordStatus.setText(R.string.unset); pinPasswordStatus.setTextColor(COLOR_WARNING); } else { boolean isPIN = CryptoUtils.isPIN(getActivity()); pinPasswordStatus.setText(isPIN ? R.string.pin : R.string.password); pinPasswordStatus.setTextColor(COLOR_OK); } LockMediator.Status status = lm.getLockMediatorStatus(); boolean isSecure = status.security || !isActive; lockscreenStatus.setText(isSecure ? R.string.enabled : R.string.bypassed); lockscreenStatus.setTextColor(isSecure ? COLOR_OK : COLOR_INFO); keyguardStatus.setText(R.string.enabled); keyguardStatus.setTextColor(COLOR_OK); getActivity().sendBroadcast(new Intent(KeyguardService.ACTION_PING)); }