本文整理了Java中android.widget.Switch.setTag()
方法的一些代码示例,展示了Switch.setTag()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Switch.setTag()
方法的具体详情如下:
包路径:android.widget.Switch
类名称:Switch
方法名:setTag
暂无
代码示例来源:origin: stackoverflow.com
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
...
// Add a switch listener
Switch mySwitch = (Switch) convertView.findViewById(R.id.mySwitch);
mySwitch.setTag(groupPosition);
mySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.e("TAG", "Clicked position: " + buttonView.getTag());
}
});
} else {
convertView.findViewById(R.id.mySwitch).setTag(groupPosition);
}
...
return convertView;
}
代码示例来源:origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE
@Override
public void onBindViewHolder(final ViewHolderEx viewHolderEx, int i) {
SubBoard board = mBoardList.get(i);
viewHolderEx.mCheckableView.setChecked(board.isChecked());
viewHolderEx.mTitleView.setText(board.getName());
if (TextUtils.isEmpty(board.getDescription())) {
viewHolderEx.mSummaryView.setVisibility(View.GONE);
} else {
viewHolderEx.mSummaryView.setVisibility(View.VISIBLE);
viewHolderEx.mSummaryView.setText(board.getDescription());
}
viewHolderEx.mCheckableView.setOnClickListener(mOnClickListener);
viewHolderEx.mCheckableView.setVisibility(board.getType() >= 0 ? View.VISIBLE : View.GONE);
viewHolderEx.itemView.setOnClickListener(mOnClickListener);
viewHolderEx.mCheckableView.setTag(board);
viewHolderEx.itemView.setTag(board);
}
代码示例来源: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: ymback/NGA-CLIENT-VER-OPEN-SOURCE
@Override
public void onBindViewHolder(UserViewHolder holder, int position) {
User user = mUserList.get(position);
holder.userNameView.setText(user.getNickName());
holder.checkView.setChecked(mUserManager.getActiveUserIndex() == position);
holder.itemView.setTag(position);
holder.checkView.setTag(position);
String avatarUrl = user.getAvatarUrl();
GlideApp.with(mContext)
.load(avatarUrl)
.placeholder(R.drawable.default_avatar)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.into(holder.avatarView);
}
代码示例来源:origin: andresth/Kandroid
toggle.setTag(position);
check.setTag(position);
代码示例来源: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: linglongxin24/ARDevelopDemo
newSwitchView.setTag(command);
newSwitchView.setVisibility(View.VISIBLE);
newSwitchView.setPadding(mEntriesSidesPadding,
代码示例来源:origin: jruesga/rview
holder.mBinding.actionsA.quote.setTag(R.id.tag_key, comment.commentA.message);
holder.mBinding.actionsA.edit.setTag(R.id.tag_key, comment.commentA.message);
holder.mBinding.actionsA.unresolved.setTag(R.id.tag_key, comment.commentA.message);
holder.mBinding.actionsB.unresolved.setTag(R.id.tag_key, comment.commentB.message);
内容来源于网络,如有侵权,请联系作者删除!