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

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

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

Switch.setText介绍

暂无

代码示例

代码示例来源:origin: googlesamples/android-WatchFace

public void setName(String name) {
  mUnreadNotificationSwitch.setText(name);
}

代码示例来源:origin: marzika/Snapprefs

private void applyLogTypeSwitches(LinearLayout layout) {
    LogType[] logTypes = Logger.LogType.values();
    final float scale = getContext().getResources().getDisplayMetrics().density;
    HashSet<String> activeTypes = Logger.getActiveLogTypes();

    for (LogType logType : logTypes) {
      Switch logSwitch = new Switch(layout.getContext());
      int pad = (int) (10f * scale);
      logSwitch.setPadding(pad, pad / 2, pad, pad / 2);
      logSwitch.setText(logType.name());
      logSwitch.setChecked(activeTypes.contains(logType.name()));
      logSwitch.setTextSize(7f * scale);
      logSwitch.setTextColor(Color.GRAY);
      logSwitch.setTag(logType.name());

      logSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean state) {
          String tag = (String) compoundButton.getTag();
          Logger.setLogTypeState(tag, state);
        }
      });

      layout.addView(logSwitch);
    }
  }
}

代码示例来源:origin: thuryn/your-local-weather

boolean dayAbbrevChecked = (dayAbbrev != null)?dayAbbrev:false;
dayNameSwitch.setChecked(dayAbbrevChecked);
dayNameSwitch.setText(getString(R.string.widget_setting_forecast_day_name_style) + " (" + (dayNameSwitch.isChecked()?textOn:textOff) + ")");
final DayNameSwitchListener dayNameSwitchListener = new DayNameSwitchListener(dayAbbrevChecked, dayNameSwitch, textOn, textOff);
dayNameSwitch.setOnCheckedChangeListener(dayNameSwitchListener);

代码示例来源:origin: Odoo-mobile/framework

setValue(getValue());
if (mLabel != null)
  mSwitch.setText(mLabel);
if (textSize > -1) {
  mSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);

代码示例来源:origin: linglongxin24/ARDevelopDemo

newSwitchView.setText(text);

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

public class ActivityClass extends Activity implements CompoundButton.OnCheckedChangeListener {
Switch list_toggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.return_vehicle);

  list_toggle=(Switch)findViewById(R.id.list_toggle);
  list_toggle.setOnCheckedChangeListener(this);
  }
}

public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
  if(isChecked) {
    list_toggle.setText("Only Today's");  //To change the text near to switch
    Log.d("You are :", "Checked");
  }
  else {
    list_toggle.setText("All List");   //To change the text near to switch
    Log.d("You are :", " Not Checked");
  }
}

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

public class ActivityClass extends Activity {
Switch list_toggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.return_vehicle);

  list_toggle=(Switch)findViewById(R.id.list_toggle);
  list_toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
     if(isChecked) {
       list_toggle.setText("Only Today's");  //To change the text near to switch
       Log.d("You are :", "Checked");
     }
     else {
       list_toggle.setText("All List");  //To change the text near to switch
       Log.d("You are :", " Not Checked");
     }
    }       
   });
  }
}

代码示例来源:origin: thuryn/your-local-weather

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  checked = isChecked;
  dayNameSwitch.setText(getString(R.string.widget_setting_forecast_day_name_style) + " (" + (isChecked ? textOn : textOff) + ")");
}

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

@Override
public View getView(final int position, View view, ViewGroup parent) {
  LayoutInflater inflater = context.getLayoutInflater();
  View rowView = inflater.inflate(R.layout.notification_list_element, null, true);

  Switch s = (Switch) rowView.findViewById(R.id.switch1);
  s.setChecked(alert.get(position));
  s.setText(titles.get(position));
  s.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      alert.set(position, isChecked);
    }
  });

  return rowView;
}

代码示例来源:origin: pili-engineering/QNRTC-Android

String videoTag = mRemoteSecondVideoTrack.getQNTrackInfo().getTag();
  if (UserTrackView.TAG_CAMERA.equals(videoTag)) {
    mSecondVideoSwitch.setText(R.string.video_camera);
  } else if (UserTrackView.TAG_SCREEN.equals(videoTag)) {
    mSecondVideoSwitch.setText(R.string.video_screen);
  } else {
    if (TextUtils.isEmpty(videoTag)) {
      mSecondVideoSwitch.setText(R.string.video_camera);
    } else {
      mSecondVideoSwitch.setText(videoTag);
  mSecondEditTextHeight.setText(String.valueOf(option.getHeight()));
} else {
  mSecondVideoSwitch.setText(R.string.video_screen);
  mSecondEditTextX.setText("-");
  mSecondEditTextY.setText("-");

代码示例来源:origin: googlesamples/android-AppRestrictionEnforcer

private void updateApprovals(Context context, String[] approvals,
               String[] selectedApprovals) {
  mCurrentRestrictions.putStringArray(RESTRICTION_KEY_APPROVALS, selectedApprovals);
  mLayoutApprovals.removeAllViews();
  for (String approval : approvals) {
    Switch sw = new Switch(context);
    sw.setText(approval);
    sw.setTag(approval);
    sw.setChecked(Arrays.asList(selectedApprovals).contains(approval));
    sw.setOnCheckedChangeListener(this);
    sw.setId(R.id.approval);
    mLayoutApprovals.addView(sw);
  }
}

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

testSwitch.setText("Example switch");
    testSwitch.setEnabled(true);
    if (testSwitch.isChecked()) {
      testSwitch.setText("ON");
    } else {
      testSwitch.setText("OFF");

代码示例来源:origin: pili-engineering/QNRTC-Android

String videoTag = mRemoteFirstVideoTrack.getQNTrackInfo().getTag();
  if (UserTrackView.TAG_CAMERA.equals(videoTag)) {
    mFirstVideoSwitch.setText(R.string.video_camera);
  } else if (UserTrackView.TAG_SCREEN.equals(videoTag)) {
    mFirstVideoSwitch.setText(R.string.video_screen);
  } else {
    if (TextUtils.isEmpty(videoTag)) {
      mFirstVideoSwitch.setText(R.string.video_camera);
    } else {
      mFirstVideoSwitch.setText(videoTag);
  mFirstEditTextHeight.setText(String.valueOf(option.getHeight()));
} else {
  mFirstVideoSwitch.setText(R.string.video_camera);
  mFirstEditTextX.setText("-");
  mFirstEditTextY.setText("-");

代码示例来源:origin: androidthings/sample-simpleui

View child = inflater.inflate(R.layout.list_item_gpio, gpioPinsView, false);
Switch button = child.findViewById(R.id.gpio_switch);
button.setText(name);
gpioPinsView.addView(button);
Log.d(TAG, "Added button for GPIO: " + name);

代码示例来源:origin: quemb/QMBForm

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void update() {
  String title = getFormItemDescriptor().getTitle();
  mSwitch.setText(title);
  if (getRowDescriptor().getDisabled())
  {
    mSwitch.setEnabled(false);
    setTextColor(mSwitch, CellDescriptor.COLOR_LABEL_DISABLED);
  }
  else
    mSwitch.setEnabled(true);
  @SuppressWarnings("unchecked") Value<Boolean> value = (Value<Boolean>) getRowDescriptor().getValue();
  if (value != null && value.getValue() != null) {
    mSwitch.setChecked(value.getValue());
  }
}

代码示例来源:origin: EthACKdotOrg/orWall

initScript.setText(getString(R.string.wizard_init_script_text));
initScript.setEnabled(initSupported);
rootStatus.setChecked(RootCommands.rootAccessGiven());
rootStatus.setEnabled(false);
rootStatus.setText(getString(R.string.wizard_init_root_text));
main_content.addView(rootStatus);
iptablesStatus.setChecked(Iptables.iptablesExists());
iptablesStatus.setEnabled(false);
iptablesStatus.setText(getString(R.string.wizard_init_iptables_text));
main_content.addView(iptablesStatus);
iptablesComments.setChecked(iptables.getSupportComment());
iptablesComments.setEnabled(false);
iptablesComments.setText(getString(R.string.wizard_init_ipt_comments_text));
main_content.addView(iptablesComments);
orbotStatus.setChecked(Util.isOrbotInstalled(getActivity()));
orbotStatus.setEnabled(false);
orbotStatus.setText(getString(R.string.wizard_orbot_status_text));
main_content.addView(orbotStatus);

相关文章