本文整理汇总了Java中android.widget.TextView.setTag方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setTag方法的具体用法?Java TextView.setTag怎么用?Java TextView.setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpReturnOrderView
import android.widget.TextView; //导入方法依赖的package包/类
private void setUpReturnOrderView(ReturnOrderDetailResponse returnOrderDetailResponse) {
TextView tv = new TextView(getActivityContext());
tv.setTextSize(14);
tv.setTextColor(Color.parseColor(getString(R.string.textColorThird)));
tv.setGravity(Gravity.CENTER_VERTICAL);
tv.setTag(returnOrderDetailResponse.getReturnOrder().getReturnOrderID());
if (!TextUtils.isEmpty(returnOrderDetailResponse.getReturnOrder().getName())) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
CommonUtils.dip2px(getActivityContext(), 40));
SpannableString ss = new SpannableString(getString(R.string.tag_return_order_num) + returnOrderDetailResponse.getReturnOrder().getName());
ss.setSpan(new ForegroundColorSpan(Color.parseColor(getString(R.string.color_return_order_num))), 5, 5 + returnOrderDetailResponse.getReturnOrder().getName().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
tv.setText(ss);
mLlReturn.addView(tv, params);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳转到退货单详情
// Intent intent = new Intent(mContext, ReturnDetailActivity.class);
// intent.putExtra("rid", returnId);
// startActivity(intent);
}
});
}
}
示例2: addTextView
import android.widget.TextView; //导入方法依赖的package包/类
private void addTextView(Context context, int viewTag) {
TextView tv = (TextView) View.inflate(context, R.layout.custom_textview, null);
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layoutParams.weight = 1.0F;
tv.setLayoutParams(layoutParams);
tv.setOnClickListener(this);
tv.setGravity(Gravity.CENTER);
if (mTextSize > 0f)
tv.setTextSize(0, mTextSize);
tv.setOnClickListener(this);
tv.setTag(viewTag);
if (viewTag == TAG_LEFT_VIEW) {
tv.setText(mLeftText);
mLeftTextView = tv;
} else if (viewTag == TAG_NONE_VIEW) {
tv.setText(mSimpleText);
mSimpleTextView = tv;
} else if (viewTag == TAG_RIGHT_VIEW) {
tv.setText(mRightText);
mRightTextView = tv;
}
addView(tv);
}
示例3: addHintIcon
import android.widget.TextView; //导入方法依赖的package包/类
public void addHintIcon(int drawableId)
{
if (this.mHintIconArray.indexOfKey(drawableId) == -1)
{
this.mHintIconArray.put(drawableId, drawableId);
TextView tv = new TextView(mContext);
tv.setTag(drawableId);
tv.setGravity(Gravity.CENTER);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(lp);
tv.setBackgroundResource(drawableId);
tv.setIncludeFontPadding(false);
this.mHintIcons.addView(tv);
}
}
示例4: getView
import android.widget.TextView; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
TrackMetaData trackMetaData= getItem(position);
if (convertView==null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.displaysongs,parent,false);
}
final TextView TrackTitle = (TextView) convertView.findViewById(R.id.song_title);
final TextView TrackAuthor = (TextView) convertView.findViewById(R.id.song_author);
TrackTitle.setOnClickListener(onClickListener);
TrackTitle.setTag(R.string.TitleTag,position);
if (trackMetaData.getISsongSelected()){
TrackTitle.setTextColor(getResources().getColor(R.color.colorTrackPlay));
Intent intent = new Intent(getContext(),TrackInfoActivity.class);
Bundle b = new Bundle();
b.putParcelable(TrackINFO,trackMetaData);
intent.putExtras(b);
startActivity(intent);
}
else{
TrackTitle.setTextColor(getResources().getColor(R.color.colorTrackDefault));
}
TrackTitle.setText(trackMetaData.getTrackTitle());
TrackAuthor.setText(trackMetaData.getTrackArtist());
return convertView;
}
示例5: getThreed
import android.widget.TextView; //导入方法依赖的package包/类
private static Threed getThreed(TextView view) {
if (view == null) {
throw new IllegalArgumentException("view must be non-null");
}
Object tag = view.getTag(R.id.threed);
if (tag instanceof Threed) {
return (Threed) tag;
}
Threed t = new Threed();
t.textView = view;
view.setTag(R.id.threed, t);
return t;
}
示例6: makeColorPresetButton
import android.widget.TextView; //导入方法依赖的package包/类
private void makeColorPresetButton(int color) {
FrameLayout outframe = new FrameLayout(getContext());
outframe.setBackgroundColor(Color.BLACK);
outframe.setPadding(6,6,6,6);
FrameLayout frame = new FrameLayout(getContext());
//frame.setBackgroundColor(Color.BLACK);
frame.setBackgroundResource(R.drawable.transparentgrid);
TextView c = new TextView(getContext());
c.setText(" ");
c.setTextSize(22);
c.setBackgroundColor(color);
// if (color==Color.TRANSPARENT) {
// c.setBackgroundResource(R.drawable.transparentgrid);
// }
c.setTag(color);
c.setClickable(true);
c.setOnClickListener(setColorListener);
frame.addView(c);
GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.setMargins(24, 16, 24, 16);
outframe.setPadding(6,6,6,6);
outframe.addView(frame);
colorPresets.addView(outframe, lp);
}
示例7: getView
import android.widget.TextView; //导入方法依赖的package包/类
@Override public View getView(int position, View convertView, ViewGroup parent) {
TextView view = (TextView) super.getView(position, convertView, parent);
view.setTextColor(Color.DKGRAY);
view.setTag("" + position);
Item item = getItem(position);
if (item.type == Item.SECTION) {
//view.setOnClickListener(PinnedSectionListActivity.this);
view.setBackgroundColor(parent.getResources().getColor(COLORS[item.sectionPosition % COLORS.length]));
}
return view;
}
示例8: init
import android.widget.TextView; //导入方法依赖的package包/类
private void init(Context context) {
setOrientation(LinearLayout.HORIZONTAL);
int paddingTopBottom = ConvertUtils.toPx(context, ITEM_PADDING_TOP_BOTTOM);
int paddingLeftRight = ConvertUtils.toPx(context, ITEM_PADDING_LEFT_RIGHT);
setPadding(paddingLeftRight, paddingTopBottom, paddingLeftRight, paddingTopBottom);
setGravity(Gravity.CENTER);
int height = ConvertUtils.toPx(context, ITEM_HEIGHT);
// fixed: 17-1-8 #79 安卓4.x兼容问题,java.lang.ClassCastException……onMeasure……
setLayoutParams(new AbsListView.LayoutParams(MATCH_PARENT, height));
imageView = new ImageView(getContext());
imageView.setTag(ITEM_TAG_IMAGE);
imageView.setVisibility(View.GONE);
LayoutParams imageParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
imageParams.rightMargin = ConvertUtils.toPx(context, ITEM_MARGIN);
addView(imageView, imageParams);
textView = new TextView(getContext());
textView.setTag(ITEM_TAG_TEXT);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setSingleLine(true);
textView.setIncludeFontPadding(false);
textView.setGravity(Gravity.CENTER);
textView.setTextColor(Color.BLACK);
LayoutParams textParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
addView(textView, textParams);
}
示例9: handleLinksWithShowMore
import android.widget.TextView; //导入方法依赖的package包/类
private static void handleLinksWithShowMore(TextView view, Post post) {
String showMore = " [详细] ";
String content = post.body + showMore;
SpannableString spannable = convertNormalStringToSpannableString(content);
spannable.setSpan(new RelativeSizeSpan(0.8f), content.length() - showMore.length(),
content.length(), 17);
spannable.setSpan(new ShowMoreSpan("showMore"), content.length() - showMore.length(),
content.length(), 17);
view.setText(spannable);
view.setTag(R.id.timeline_post_id, Integer.valueOf(post.id));
}
示例10: setCountText
import android.widget.TextView; //导入方法依赖的package包/类
public static ObjectAnimator setCountText(TextView view, int count, boolean animate) {
if (Objects.nonNull(view)) {
if (animate) {
ObjectAnimator animator = ObjectAnimator.ofInt(view, createAmountAnimatorProperty(DEFAULT_COUNT_FORMATTER), count);
animator.setDuration(250);
animator.start();
return animator;
} else {
view.setTag(count);
view.setText(DEFAULT_COUNT_FORMATTER.format(count));
}
}
return null;
}
示例11: getLoadingView
import android.widget.TextView; //导入方法依赖的package包/类
private View getLoadingView() {
TextView tv = new TextView(this);
tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
tv.setText("Helper中定义的加载中");
tv.setGravity(Gravity.CENTER);
tv.setTextSize(18);
tv.setTextColor(Color.RED);
// 设置tag为loading
tv.setTag(StatusLayout.Status.LOADING.getStatus());
return tv;
}
示例12: instantiateItem
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
Log.i(TAG, "instantiateItem>>>" + position);
View child = chilren.get(position);
if (child == null) {
child = inflater.inflate(R.layout.target_poi_item_detail, null);
chilren.put(position, child);
}
child.findViewById(R.id.tpid_target_confirm_bt).setOnClickListener(clickListener);
child.findViewById(R.id.tpid_target_confirm_bt).setTag(position);
((TextView) child.findViewById(R.id.tpid_name_text)).setText((position + 1) + "." + aList.get(position).getName());
((TextView) child.findViewById(R.id.tpid_address_text)).setText(aList.get(position).getAddress());
Double distance = DistanceUtil.getDistance(new LatLng(address.getLatitude(), address.getLongitude()),
poiInfoList.get(position).location) / 1000;
((TextView) child.findViewById(R.id.tpid_distance_text)).setText(String.format("%.1f", distance) + "km");
child.findViewById(R.id.tpid_set_target_bt).setOnClickListener(clickListener);
child.findViewById(R.id.tpid_set_target_bt).setTag(position);
TextView ft = (TextView) child.findViewById(R.id.tpid_favorite_bt);
ft.setOnClickListener(clickListener);
ft.setTag(position);
if (aList.get(position).getFavoritedTime() != null) {
ft.setText("已收藏");
((LevelListDrawable) ft.getBackground()).setLevel(1);
}
container.addView(child, 0);
return chilren.get(position);
}
示例13: addTask
import android.widget.TextView; //导入方法依赖的package包/类
public void addTask(View view) {
//模拟路径
String path = "/sdcard/imgs/" + (++i) + ".png";
MyIntentService.startUploadImg(this, path);
TextView tv = new TextView(this);
mLyTaskContainer.addView(tv);
tv.setText(path + " is uploading ...");
tv.setTag(path);
}
示例14: getItemView
import android.widget.TextView; //导入方法依赖的package包/类
private View getItemView(int position){
TextView textView = new TextView(mContext);
textView.setTextAppearance(mContext, R.style.switcher_item_text_style);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
DensityUtil.dip2px(mContext,40));
textView.setLayoutParams(layoutParams);
textView.setSelected(position == mDefaultSelection);
textView.setGravity(Gravity.CENTER);
textView.setText(mAllItemArray.get(position));
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.0f);
textView.setOnClickListener(mItemOnClickListener);
textView.setTag(position);
return textView;
}
示例15: DrawableGetter
import android.widget.TextView; //导入方法依赖的package包/类
public DrawableGetter(TextView tv, int width) {
tv.setTag(R.id.drawable_callback, this);
this.container = new WeakReference<>(tv);
this.cachedTargets = new HashSet<>();
this.width = width;
}