android.widget.CheckBox.getText()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(166)

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

CheckBox.getText介绍

暂无

代码示例

代码示例来源:origin: labexp/osmtracker-android

private void selectLayout(CheckBox pressed){
  selected.setChecked(false);
  pressed.setChecked(true);
  selected=pressed;
  String targetLayout = layoutsFileNames.get(pressed.getText());
  prefs.edit().putString(OSMTracker.Preferences.KEY_UI_BUTTONS_LAYOUT,
      targetLayout).commit();
}

代码示例来源:origin: WomenWhoCode/WomenWhoCode

private JSONArray getAnswersArray(View view) {
  final JSONArray ja = new JSONArray();
  RelativeLayout formLayout = (RelativeLayout) view.getParent();
  EditText etOther = (EditText) formLayout.findViewById(R.id.etOther);
  LinearLayout layout = (LinearLayout) formLayout.findViewById(R.id.chkLayout);
  for (int i = 0; i < layout.getChildCount(); i++) {
    CheckBox cb = (CheckBox) layout.getChildAt(i);
    if (cb.isChecked()) {
      ja.put(cb.getText());
    }
  }
  if (etOther.getText().length() > 0) {
    ja.put(etOther.getText());
  }
  return ja;
}

代码示例来源:origin: termux/termux-api

@Override
  String getResult() {
    int checkBoxCount = widgetView.getChildCount();
    List<Value> values = new ArrayList<>();
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    for (int j = 0; j < checkBoxCount; ++j) {
      CheckBox box = widgetView.findViewById(j);
      if (box.isChecked()) {
        Value value = new Value();
        value.index = j;
        value.text = box.getText().toString();
        values.add(value);
        sb.append(box.getText().toString()).append(", ");
      }
    }
    inputResult.values = values;
    // remove trailing comma and add closing bracket
    return sb.toString().replaceAll(", $", "") + "]";
  }
}

代码示例来源:origin: lltvcn/FreeText

@Override
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if(isChecked){
      if(lastCK!=null){
        lastCK.setChecked(false);
      }
      lastCK = (CheckBox) buttonView;
      setString(lastCK.getText().toString());
    }else {
      lastCK = null;
      try {
        field.set(data,null);
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }
    }
  }
};

代码示例来源:origin: huxq17/SwipeCardsView

/**
 * 获取edittext,textView,checkbox和button的文字
 *
 * @param obj
 * @return
 */
public String getText(Object obj) {
  if (obj instanceof TextView) {
    return ((TextView) obj).getText().toString();
  }
  if (obj instanceof EditText) {
    return ((EditText) obj).getText().toString();
  }
  if (obj instanceof Button) {
    return ((Button) obj).getText().toString();
  }
  if (obj instanceof CheckBox) {
    return ((CheckBox) obj).getText().toString();
  }
  return "";
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
  public void onClick(DialogInterface dialog, int which) {
    statusLog("Everything went fine, chroot is installed. Selecting metapackages.");
    StringBuilder sb = new StringBuilder("");
    CheckBox cb;
    // now grab all the checkboxes in the dialog and check their status
    // thanks to "user2" for a 2-line sample of how to get the dialog's view:  http://stackoverflow.com/a/13959585/3035127
    AlertDialog d = AlertDialog.class.cast(dialog);
    LinearLayout ll = (LinearLayout) d.findViewById(R.id.metapackageLinearLayout);
    int children = ll.getChildCount();
    for (int cnt = 0; cnt < children; cnt++) {
      if (ll.getChildAt(cnt) instanceof CheckBox) {
        cb = (CheckBox) ll.getChildAt(cnt);
        if (cb.isChecked()) {
          sb.append(cb.getText()).append(" ");
        }
      }
    }
    installAndUpgrade(sb.toString());
  }
});

代码示例来源:origin: huxq17/tractor

/**
 * 获取edittext,textView,checkbox和button的文字
 *
 * @param obj
 * @return
 */
public String getText(Object obj) {
  if (obj instanceof TextView) {
    return ((TextView) obj).getText().toString();
  }
  if (obj instanceof EditText) {
    return ((EditText) obj).getText().toString();
  }
  if (obj instanceof Button) {
    return ((Button) obj).getText().toString();
  }
  if (obj instanceof CheckBox) {
    return ((CheckBox) obj).getText().toString();
  }
  return "";
}

代码示例来源:origin: labexp/osmtracker-android

if(defCheck instanceof CheckBox){
  CheckBox defCheckCast = (CheckBox) defCheck;
  String defCheckName = layoutsFileNames.get(defCheckCast.getText());
  if (activeLayoutName.equals(defCheckName)) {
    selected = defCheckCast;
    if (current instanceof CheckBox) {
      CheckBox currentCast = (CheckBox) current;
      String currentName = layoutsFileNames.get(currentCast.getText());
      if (activeLayoutName.equals(currentName)) {
        selected = currentCast;
    String targetLayout = layoutsFileNames.get(selected.getText());
    prefs.edit().putString(OSMTracker.Preferences.KEY_UI_BUTTONS_LAYOUT,
        targetLayout).commit();

代码示例来源:origin: EmpireProject/EmpireMobile

public void onClick(View v){
  b = (CheckBox)v;
  String names = b.getText().toString();
  http3 = "https://".concat(address).concat("/api/agents/").concat(names).concat("?token=").concat(token);
        String Id = jObj1.getString("name");
        if (Id.equals(b.getText())) {
          checkin_time.append(" [*] STALE AGENT");
        } else {

代码示例来源:origin: EmpireProject/EmpireMobile

public void onClick(View v){
  b = (CheckBox)v;
  String names = b.getText().toString();
  http3 = "https://".concat(address).concat("/api/agents/").concat(names).concat("?token=").concat(token);
        String Id = jObj1.getString("name");
        if (Id.equals(b.getText())) {
          checkin_time.append(" [*] STALE AGENT");
        } else {

代码示例来源:origin: labexp/osmtracker-android

String layoutName = checkboxHeld.getText().toString();
String iso = getIso(layoutsFileNames.get(checkboxHeld.getText()));
String info[]= {layoutName, iso};
final ProgressDialog dialog = new ProgressDialog(checkboxHeld.getContext());
setTitle(checkboxHeld.getText())
.setMessage(getResources().getString(R.string.buttons_presets_delete_message).replace("{0}", checkboxHeld.getText()))
.setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert)

代码示例来源:origin: arminha/worldclockwidget

mUseInWidgetCheckBox.setText(mUseInWidgetCheckBox.getText().toString().toUpperCase());

代码示例来源:origin: labexp/osmtracker-android

defaultCheckBox.setOnClickListener(listener);
layoutsFileNames.put(defaultCheckBox.getText().toString(),OSMTracker.Preferences.VAL_UI_BUTTONS_LAYOUT);

代码示例来源:origin: advanced-android-book/samples

if (extendCheckBox.isChecked()) {
  final PendingIntent pendingIntent = PendingIntent.getActivity(this, 3, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
  builder.extend(new NotificationCompat.WearableExtender().addAction(new NotificationCompat.Action(R.drawable.ic_stat_name, action3CheckBox.getText(), pendingIntent)));

相关文章