android.widget.Switch.isChecked()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(566)

本文整理了Java中android.widget.Switch.isChecked()方法的一些代码示例,展示了Switch.isChecked()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Switch.isChecked()方法的具体详情如下:
包路径:android.widget.Switch
类名称:Switch
方法名:isChecked

Switch.isChecked介绍

暂无

代码示例

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 获取switch状态
 *
 * @return 返回switch当前选中状态
 */
public boolean getSwitchIsChecked() {
  boolean isChecked = false;
  if (mSwitch != null) {
    isChecked = mSwitch.isChecked();
  }
  return isChecked;
}

代码示例来源:origin: guardianproject/haven

public void checkCallToVerify (View v) {
    Switch callSwitch = v.findViewById(R.id.signalCallSwitch);
    if (callSwitch != null && callSwitch.isChecked()) {
      preferences.setVoiceVerification(true);
    } else {
      preferences.setVoiceVerification(false);
    }
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

public void onConnectionChange() {
 if (binding.connected.isChecked()) {
  binding.connected.setEnabled(false);
  connectionSub=rxBluetooth.observeConnectDevice(getDevice(), ShoutingEchoService.SERVICE_ID)
   .subscribeOn(Schedulers.io())
   .observeOn(AndroidSchedulers.mainThread())
   .subscribe(this::onConnected, this::onConnectionError);
 }
 else {
  disconnect();
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void manageExact(boolean start) {
 if (start) {
  long period=getPeriod();
  PollReceiver.scheduleExactAlarm(this, alarms, period,
    download.isChecked());
 }
 else {
  PollReceiver.cancelAlarm(this, alarms);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void manageExact(boolean start) {
 if (start) {
  long period=getPeriod();
  PollReceiver.scheduleExactAlarm(this, alarms, period,
    download.isChecked());
 }
 else {
  PollReceiver.cancelAlarm(this, alarms);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void manageInexact(boolean start) {
 if (start) {
  long period=getPeriod();
  PollReceiver.scheduleInexactAlarm(this, alarms, period,
    download.isChecked());
 }
 else {
  PollReceiver.cancelAlarm(this, alarms);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void manageInexact(boolean start) {
 if (start) {
  long period=getPeriod();
  PollReceiver.scheduleInexactAlarm(this, alarms, period,
    download.isChecked());
 }
 else {
  PollReceiver.cancelAlarm(this, alarms);
 }
}

代码示例来源:origin: facebook/facebook-android-sdk

boolean isOn = ((Switch)view).isChecked();
textObj = isOn ? "1" : "0";

代码示例来源:origin: commonsguy/cw-omnibus

@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
private void manageJobScheduler(boolean start) {
 JobScheduler jobs=
  (JobScheduler)getSystemService(JOB_SCHEDULER_SERVICE);
 if (start) {
  JobInfo.Builder b=new JobInfo.Builder(JOB_ID,
    new ComponentName(this, DemoJobService.class));
  PersistableBundle pb=new PersistableBundle();
  if (download.isChecked()) {
   pb.putBoolean(KEY_DOWNLOAD, true);
   b.setExtras(pb).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
  } else {
   b.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE);
  }
  b.setPeriodic(getPeriod()).setPersisted(false)
    .setRequiresCharging(false).setRequiresDeviceIdle(true);
  jobs.schedule(b.build());
 }
 else {
  jobs.cancel(JOB_ID);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void manageJobScheduler(boolean start) {
 if (start) {
  JobInfo.Builder b=new JobInfo.Builder(JOB_ID,
    new ComponentName(this, DemoJobService.class));
  PersistableBundle pb=new PersistableBundle();
  if (download.isChecked()) {
   pb.putBoolean(KEY_DOWNLOAD, true);
   b.setExtras(pb).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
  } else {
   b.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE);
  }
  b.setPeriodic(getPeriod()).setPersisted(false)
    .setRequiresCharging(false).setRequiresDeviceIdle(true);
  jobs.schedule(b.build());
 }
 else {
  jobs.cancel(JOB_ID);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void manageUnified(boolean start) {
 if (start) {
  final JobRequest.Builder b=
   new JobRequest.Builder(DemoUnifiedJob.JOB_TAG);
  PersistableBundleCompat extras=new PersistableBundleCompat();
  if (download.isChecked()) {
   extras.putBoolean(KEY_DOWNLOAD, true);
   b
    .setExtras(extras)
    .setRequiredNetworkType(JobRequest.NetworkType.CONNECTED);
  }
  else {
   b.setRequiredNetworkType(JobRequest.NetworkType.ANY);
  }
  b
   .setPeriodic(getPeriod())
   .setRequiresCharging(false)
   .setRequiresDeviceIdle(true);
  unifiedJobId=b.build().schedule();
 }
 else {
  JobManager.instance().cancel(unifiedJobId);
 }
}

代码示例来源:origin: julian-klode/dns66

@Override
  public void onClick(View view) {
    holder.whitelistSwitch.setChecked(!holder.whitelistSwitch.isChecked());
  }
});

代码示例来源:origin: willowtreeapps/Hyperion-Android

@Override
  public void onClick(View v) {
    final MutableBooleanViewAttribute attribute = getData();
    attribute.setValue(booleanSwitch.isChecked());
  }
}

代码示例来源:origin: stackoverflow.com

public void ParentLayoutClicked(View _v){

  Switch _Switch_Internet = (Switch) findViewById(R.id.m_switch_internet);

    if(_Switch_Internet.isChecked()){
      _Switch_Internet.setChecked(false);         
    }
    else{
      _Switch_Internet.setChecked(true);  
  }       
}

代码示例来源:origin: julian-klode/dns66

public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {
      case R.id.action_delete:
        Intent deleteIntent = new Intent();
        deleteIntent.putExtra("DELETE", true);
        setResult(RESULT_OK, deleteIntent);
        finish();
        break;
      case R.id.action_save:
        Intent intent = new Intent();
        intent.putExtra("ITEM_TITLE", titleText.getText().toString());
        intent.putExtra("ITEM_LOCATION", locationText.getText().toString());
        if (stateSpinner != null)
          intent.putExtra("ITEM_STATE", stateSpinner.getSelectedItemPosition());
        if (stateSwitch != null)
          intent.putExtra("ITEM_STATE", stateSwitch.isChecked() ? 1 : 0);
        setResult(RESULT_OK, intent);
        finish();
        break;
    }

    return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: hypertrack/smart-scheduler-android

private Job createJob() {
  int jobType = getJobType();
  int networkType = getNetworkTypeForJob();
  boolean requiresCharging = requiresChargingSwitch.isChecked();
  boolean isPeriodic = isPeriodicSwitch.isChecked();
  String intervalInMillisString = intervalInMillisEditText.getText().toString();
  if (TextUtils.isEmpty(intervalInMillisString)) {
    return null;
  }
  Long intervalInMillis = Long.parseLong(intervalInMillisString);
  Job.Builder builder = new Job.Builder(JOB_ID, this, jobType, JOB_PERIODIC_TASK_TAG)
      .setRequiredNetworkType(networkType)
      .setRequiresCharging(requiresCharging)
      .setIntervalMillis(intervalInMillis);
  if (isPeriodic) {
    builder.setPeriodic(intervalInMillis);
  }
  return builder.build();
}

代码示例来源:origin: stackoverflow.com

ImageView image = (ImageView)findViewById(R.id.obamahere);
  final Switch o = (Switch)findViewById(R.id.obamaswitch);
if (o.isChecked()){
image.setImageResource(R.drawble.icon);
  }

代码示例来源:origin: trishika/DroidUPnP

private void setSwitchChecked(boolean checked)
{
  if (checked != mSwitch.isChecked())
    mSwitch.setChecked(checked);
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

@Override
  public void onClick(View v) {
    sw.setChecked(!sw.isChecked());
  }
});

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

@Override
  public void onClick(final View v) {
    Switch keyboard = (Switch) findViewById(R.id.activity_setting_hogp_keyboard);
    keyboard.setChecked(!keyboard.isChecked());
  }
});

相关文章