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

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

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

CheckBox.setTag介绍

暂无

代码示例

代码示例来源:origin: ukanth/afwall

private CheckBox addSupport(CheckBox check, PackageInfoData app, int flag) {
  if (check != null) {
    check.setTag(app);
    switch (flag) {
      case 0:
        check.setChecked(app.selected_roam);
        break;
      case 1:
        check.setChecked(app.selected_vpn);
        break;
      case 2:
        check.setChecked(app.selected_lan);
        break;
      case 3:
        check.setChecked(app.selected_tor);
        break;
    }
  }
  return check;
}

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
   LinearLayout view = (LinearLayout) convertView;
   if (view == null) {
     view = (LinearLayout) inflater.inflate(R.layout.record_view_start, parent, false);
   }
   TextView tv = (TextView) view.findViewById(R.id.engName);
   tv.setText(getItem(position));
   CheckBox cBox = (CheckBox) view.findViewById(R.id.checkBox1);
   cBox.setTag(Integer.valueOf(position)); // set the tag so we can identify the correct row in the listener
   cBox.setChecked(mChecked[position]); // set the status as we stored it        
   cBox.setOnCheckedChangeListener(mListener); // set the listener    
   return view;
}

OnCheckedChangeListener mListener = new OnCheckedChangeListener() {

   public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {   
     mChecked[(Integer)buttonView.getTag()] = isChecked; // get the tag so we know the row and store the status 
   }
};

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

checks.setTag(position);

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

tv.setText("Name :"+ name1.get(position));
tv1.setText("Phone No :"+ phno1.get(position));
cb.setTag(position);
cb.setChecked(mCheckStates.get(position, false));
cb.setOnCheckedChangeListener(this);

代码示例来源:origin: ukanth/afwall

holder.box_wifi.setTag(holder.app);
holder.box_wifi.setChecked(holder.app.selected_wifi);
  holder.box_3g.setTag(holder.app);
  holder.box_3g.setChecked(holder.app.selected_3g);

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

final CheckBox cb = (CheckBox) convertView.findViewById(R.id.cbList_hook);

boolean isChecked = topicsList.get(position).isChecked();

cb.setChecked(isChecked);

//Set a tag on the cb, to know which object it corresponds with
cb.setTag(topicsList.get(position));

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

CheckBox Chk = (CheckBox) convertView.findViewById(R.id.ColChk);
Chk.setTag(MyArrList.get(position).get("RbMjere"));
Chk.setChecked(commentTexts.get(position));

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

CheckBox chkSelect =(CheckBox) item.findViewById(R.id.CheckBox
 android:id="@+id/checkBox_atomic_list_item_type_id");
 chkSelect.setTag(position);
 chkSelect.setChecked(mCheckStates.get(position, false));
 chkSelect.setOnCheckedChangeListener(this);

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

public View getView(int position, View convertView, ViewGroup parent) {
  View view = convertView;

  if (view == null) {
    LayoutInflater layoutInflater = context.getLayoutInflater();
    view = layoutInflater.inflate(R.layout.alerts_list_line, null);
  }

  CheckBox cb = (CheckBox) view.findViewById(R.id.cb_list_line);
  cb.setTag(id);

  List<String> list = .getFavoriteId();

  if (list .contains(String.valueOf(info.getId())))
    cb.setChecked(true);
  else
    cb.setChecked(false);
  return view;
}

代码示例来源:origin: 8enet/AppOpsX

@Override
public void onBindViewHolder(@NonNull ExportAdapter.ExportViewHolder holder, int position) {
 holder.bindData(appInfos.get(position));
 holder.itemView.setOnClickListener(this);
 holder.itemView.setTag(holder);
 holder.checkBox.setTag(holder);
 holder.checkBox.setOnCheckedChangeListener(null);
 holder.checkBox.setChecked(isChecked(position));
 holder.checkBox.setOnCheckedChangeListener(this);
}

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

public View getView(int position, View convertView, final ViewGroup parent) {
 View vi = convertView;
 if (convertView == null)
   vi = inflater.inflate(R.layout.list_equipment_search, null);
 enter code here
 TextView serialno = (TextView) vi.findViewById(R.id.txtSerialNo); // Serial No
 TextView unitno = (TextView) vi.findViewById(R.id.txtUnitNo);
CheckBox checkbox = (CheckBox) row.findViewById(R.id.chkEquipment);
   checkbox.setTag(new Integer(position));
   checkbox.setOnCheckedChangeListener(null);
     if (checkBoxState[position])
       checkbox.setChecked(true);
     else
       checkbox.setChecked(false);
   checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
     public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
       Integer pos = (Integer) buttonView.getTag();
       if (isChecked) {
         checkBoxState[pos.intValue()] = true;
       } else {
         checkBoxState[pos.intValue()] = false;
       }
     }
   });

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  View view = convertView;
  if(view == null){
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.row_layout, null);
  }

  TextView textView = (TextView) view.findViewById(R.id.title);
  textView.setText(values[position]);

  CheckBox box = (CheckBox) view.findViewById(R.id.chk);
  box.setTag(position);
  box.setOnCheckedChangeListener(this);
  box.setChecked(checkedStatus[position]);

  view.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
    // on each click change the state of checkbox
    box.setChecked(!box.isChecked());
    }
  });

  return view;
}

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

boolean[] itemChecked =  new boolean[100];  
public View getView(int pos, View inView, ViewGroup parent) {     

 final CheckBox checkBox = (CheckBox) v.findViewById(R.id.bcheck); 

 checkBox.setTag(pos);  checkBox.setOnClickListener(new OnClickListener()
 {     
 @Override    
  public void onClick(View arg0)
{     
     String position = (String) checkBox.getTag();      

 if (checkBox.isChecked() == true) {       

 itemChecked[Integer.valueOf(position)] = checkBox.isChecked();     

 } else {  

  itemChecked[Integer.valueOf(position)] = checkBox.isChecked();       
 }          }  }); 

checkBox.setChecked(itemChecked[pos]);  

 return (v);  }

代码示例来源:origin: oswaldo89/LatestPhotoGallery-library

@Override
public void onBindViewHolder(ItemRowHolder view, final int i) {
  Glide.with(context).load(new File(item.get(i).getImgPath().getAbsolutePath())).into(view._imagenItem);
  view._chkSelected.setChecked(item.get(i).isSelected());
  view._chkSelected.setTag(item.get(i));
  view._chkSelected.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
      CheckBox cb = (CheckBox) v;
      Image contact = (Image) cb.getTag();
      contact.setSelected(cb.isChecked());
      item.get(i).setSelected(cb.isChecked());
    }
  });
}

代码示例来源:origin: Meiqia/MeiqiaSDK-Android

private void initData() {
  try {
    JSONArray choiceArray = new JSONArray(choices);
    for (int i = 0; i < choiceArray.length(); i++) {
      CheckBox checkBox = (CheckBox) getLayoutInflater().inflate(R.layout.mq_item_form_checkbox, null);
      checkBox.setText(choiceArray.getString(i));
      checkBox.setOnCheckedChangeListener(this);
      checkBox.setTag(choiceArray.get(i));
      MQUtils.tintCompoundButton(checkBox, R.drawable.mq_checkbox_uncheck, R.drawable.mq_checkbox_unchecked);
      checkboxContainer.addView(checkBox, LinearLayout.LayoutParams.MATCH_PARENT, MQUtils.dip2px(MQCollectInfoActivity.this, 48));
      checkBoxList.add(checkBox);
    }
  } catch (JSONException e) {
    rootView.setVisibility(View.GONE);
    e.printStackTrace();
  }
}

代码示例来源:origin: Chion82/WeChatMomentStat-Android

protected void loadUserList() {
  LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container);
  ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList;
  checkBoxList.clear();
  userListContainer.removeAllViews();
  for (int i=0;i<userSnsList.size();i++) {
    CheckBox userCheckBox = new CheckBox(this);
    userCheckBox.setText(userSnsList.get(i).userName + "(" + userSnsList.get(i).userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsList.get(i).snsList.size()) + ")");
    userListContainer.addView(userCheckBox);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams();
    layoutParams.setMargins(5, 5, 5, 5);
    userCheckBox.setLayoutParams(layoutParams);
    userCheckBox.setChecked(true);
    userCheckBox.setTag(userSnsList.get(i).userId);
    checkBoxList.add(userCheckBox);
  }
}

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

@Override
public void onBindViewHolder(final ViewHolder viewHolder, int position) {
  final int pos = position;
  viewHolder.tvName = (TextView) viewHolder.itemView.getChildAt(0);
  viewHolder.chkSelected = (CheckBox) viewHolder.itemView.getChildAt(1);
  viewHolder.tvName.setText(friendList.get(position).getName());
  viewHolder.chkSelected.setChecked(friendList.get(position).isSelected());
  viewHolder.chkSelected.setTag(friendList.get(position));
  viewHolder.chkSelected.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
      CheckBox cb = (CheckBox) v;
      Friend contact = (Friend) cb.getTag();
      contact.setSelected(cb.isChecked());
      friendList.get(pos).setSelected(cb.isChecked());
    }
  });
}

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

private void buildScopeCheckBoxes() {
  final List<Scope> scopes = (BuildConfig.INCLUDE_INTERNAL_API_TEST)?
    Arrays.asList(Scope.PROFILE,
        Scope.FRIEND,
        Scope.GROUP,
        Scope.MESSAGE,
        Scope.OPENID_CONNECT,
        Scope.OC_EMAIL,
        Scope.OC_PHONE_NUMBER,
        Scope.OC_GENDER,
        Scope.OC_BIRTHDATE,
        Scope.OC_ADDRESS,
        Scope.OC_REAL_NAME)
  :
    Arrays.asList(Scope.PROFILE, Scope.OPENID_CONNECT);
  final FragmentActivity activity = getActivity();
  for (final Scope scope : scopes) {
    final CheckBox checkBox = new CheckBox(activity);
    checkBox.setText(scope.getCode());
    checkBox.setTag(scope);
    scopeCheckboxLayout.addView(checkBox);
    scopeCheckBoxes.add(checkBox);
  }
}

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

@Override
public void onBindViewHolder(final ViewHolder viewHolder, int position) {
  final int pos = position;
  viewHolder.tvName = (TextView) viewHolder.itemView.getChildAt(0);
  viewHolder.chkSelected = (CheckBox) viewHolder.itemView.getChildAt(1);
  viewHolder.tvName.setText(friendList.get(position).getDisplayName());
  viewHolder.tvName.setHint(friendList.get(position).getName());
  viewHolder.chkSelected.setChecked(friendList.get(position).isSelected());
  viewHolder.chkSelected.setTag(friendList.get(position));
  viewHolder.chkSelected.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
      CheckBox cb = (CheckBox) v;
      Friend contact = (Friend) cb.getTag();
      contact.setSelected(cb.isChecked());
      friendList.get(pos).setSelected(cb.isChecked());
    }
  });
}

代码示例来源:origin: kollerlukas/Camera-Roll-Android-App

@Override
public void setFile(File_POJO file) {
  super.setFile(file);
  CheckBox checkBox = itemView.findViewById(R.id.checkbox);
  checkBox.setTag(file.getPath());
  setOnCheckedChangeListener(null);
  checkBox.setChecked(file.excluded);
  ArrayList<String> excludedPaths = Provider.getExcludedPaths();
  boolean enabled = !Provider.isDirExcludedBecauseParentDirIsExcluded(
      file.getPath(), excludedPaths);
  checkBox.setEnabled(enabled);
}

相关文章