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

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

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

CheckBox.setId介绍

暂无

代码示例

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

/**
 * 初始化RightCheckBox
 */
private void initRightCheckBox() {
  if (rightCheckBox == null) {
    rightCheckBox = new CheckBox(mContext);
  }
  rightCheckBoxParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  rightCheckBoxParams.addRule(ALIGN_PARENT_RIGHT, TRUE);
  rightCheckBoxParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
  rightCheckBoxParams.setMargins(0, 0, rightCheckBoxMarginRight, 0);
  rightCheckBox.setId(R.id.sRightCheckBoxId);
  rightCheckBox.setLayoutParams(rightCheckBoxParams);
  if (rightCheckBoxBg != null) {
    rightCheckBox.setGravity(CENTER_IN_PARENT);
    rightCheckBox.setButtonDrawable(rightCheckBoxBg);
  }
  rightCheckBox.setChecked(isChecked);
  rightCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      if (checkBoxCheckedChangeListener != null) {
        checkBoxCheckedChangeListener.onCheckedChanged(buttonView, isChecked);
      }
    }
  });
  addView(rightCheckBox);
}

代码示例来源:origin: dkharrat/NexusDialog

@Override
protected View createFieldView() {
  LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  ViewGroup checkboxContainer = (ViewGroup) inflater.inflate(R.layout.form_checkbox_container, null);
  CheckBox checkBox;
  int nbItem = items.size();
  for (int index = 0; index < nbItem; index++) {
    checkBox = new CheckBox(getContext());
    checkBox.setText(items.get(index));
    checkBox.setId(CHECKBOX_ID + index);
    checkBox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        int position = buttonView.getId() - CHECKBOX_ID;
        Object value = areValuesDefined() ? values.get(position): position;
        Set<Object> modelValues = new HashSet<>(retrieveModelValues());
        if (isChecked) {
          modelValues.add(value);
        } else {
          modelValues.remove(value);
        }
        getModel().setValue(getName(), modelValues);
      }
    });
    checkboxContainer.addView(checkBox);
    refresh(checkBox, index);
  }
  return checkboxContainer;
}

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

cb.setText(allNames.get(i));
cb.setTextColor(Color.WHITE);
cb.setId(i);
cb.setOnClickListener(MyListener);

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

cb.setText(allNames.get(i));
cb.setTextColor(Color.WHITE);
cb.setId(i);
cb.setOnClickListener(MyListener);

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

@Override
LinearLayout createWidgetView(AppCompatActivity activity) {
  LinearLayout layout = new LinearLayout(activity);
  layout.setOrientation(LinearLayout.VERTICAL);
  LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
  layoutParams.topMargin = 32;
  layoutParams.bottomMargin = 32;
  String[] values = getInputValues(activity.getIntent());
  for (int j = 0; j < values.length; ++j) {
    String value = values[j];
    CheckBox checkBox = new CheckBox(activity);
    checkBox.setText(value);
    checkBox.setId(j);
    checkBox.setTextSize(18);
    checkBox.setPadding(16, 16, 16, 16);
    checkBox.setLayoutParams(layoutParams);
    layout.addView(checkBox);
  }
  return layout;
}

代码示例来源:origin: sytolk/TaxiAndroidOpen

} else cb.setText(group.getDescription());
cb.setId(group.getGroupsId());
if (groupsMap != null && containsGroup(groupsMap, group.getGroupsId())) {
  cb.setChecked(true);

代码示例来源:origin: GeoODK/collect

mTriggerButton.setId(QuestionWidget.newUniqueId());
mTriggerButton.setText(getContext().getString(R.string.trigger));
mTriggerButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

代码示例来源:origin: GeoODK/collect

CheckBox c = new CheckBox(getContext());
c.setTag(Integer.valueOf(i));
c.setId(QuestionWidget.newUniqueId());
c.setFocusable(!prompt.isReadOnly());
c.setEnabled(!prompt.isReadOnly());

代码示例来源:origin: swentel/indigenous-android

ch.setId(i);
syndicationLayout.addView(ch);

代码示例来源:origin: posm/OpenMapKitAndroid

checkBox.toggle();
checkBox.setId(id);
odkTag.putButtonIdToTagItemHash(id++, item);
odkTag.addCheckbox(checkBox);

代码示例来源:origin: GeoODK/collect

c.setId(QuestionWidget.newUniqueId());
c.setText(prompt.getSelectChoiceText(mItems.get(i)));
c.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

相关文章