本文整理匯總了Java中android.widget.ImageView.setTag方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setTag方法的具體用法?Java ImageView.setTag怎麽用?Java ImageView.setTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setTag方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setContentImageDrawable
import android.widget.ImageView; //導入方法依賴的package包/類
public void setContentImageDrawable(Drawable imageDrawable) {
if (imageDrawable != null) {
LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView imageView = (ImageView) layoutInflater.inflate(R.layout.cfdialog_imageview_header, cfDialogHeaderLinearLayout).findViewById(R.id.cfdialog_imageview_content);
imageView.setImageDrawable(imageDrawable);
imageView.setTag(111);
cfDialogHeaderLinearLayout.setVisibility(View.VISIBLE);
} else {
for (int i = 0; i < cfDialogHeaderLinearLayout.getChildCount(); i++) {
View view = cfDialogHeaderLinearLayout.getChildAt(i);
if (view instanceof ImageView && (int) view.getTag() == 111) {
cfDialogHeaderLinearLayout.removeView(view);
cfDialogHeaderLinearLayout.setVisibility(View.GONE);
break;
}
}
}
}
示例2: onBindViewHolder
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (VIEW_TYPE_ITEM == getItemViewType(position)) {
if ((position - 1) % 5 == 0) {
((ImageViewHolder) holder).tvTime.setVisibility(View.VISIBLE);
((ImageViewHolder) holder).tvTime.setText(timeFormat((position - 1) * 2));
} else {
((ImageViewHolder) holder).tvTime.setVisibility(View.GONE);
}
String filePath = mPicturePathList.get(position - 1);
ImageView imageView = ((ImageViewHolder) holder).ivImage;
imageView.setTag(filePath);
setImageView(filePath, imageView);
} else {
if (position == 0) {
((HeaderHolder) holder).ivSpot.setVisibility(View.GONE);
} else {
((HeaderHolder) holder).ivSpot.setVisibility(View.VISIBLE);
((HeaderHolder) holder).tvTime.setVisibility(View.VISIBLE);
}
}
}
示例3: onCreate
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo_carousel);
AmbientMode.attachAmbientSupport(this);
// Grab reference to each image in activity_photo_carousel.
ImageView catImage = findViewById(R.id.cat_image);
catImage.setTag(R.drawable.cats);
catImage.setOnClickListener(this);
ImageView dogImage = findViewById(R.id.dog_image);
dogImage.setTag(R.drawable.dog);
dogImage.setOnClickListener(this);
ImageView hamsterImage = findViewById(R.id.hamster_image);
hamsterImage.setTag(R.drawable.hamster);
hamsterImage.setOnClickListener(this);
ImageView birdImage = findViewById(R.id.bird_image);
birdImage.setTag(R.drawable.birds);
birdImage.setOnClickListener(this);
}
示例4: loadImage
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Nonblocking call, return null if the bitmap is not in cache.
* @param r
* @return
*/
public Bitmap loadImage( LoadRequest r ) {
if(r == null || r.getUri() == null || TextUtils.isEmpty(r.getUri().toString()))
throw new IllegalArgumentException( "null or empty request");
ImageView iv = r.getImageView();
if(iv != null){
synchronized ( iv ) {
iv.setTag(r.getUri()); // bind URI to the ImageView, to prevent image write-back of earlier requests.
}
}
String key = r.getHashedUri();
if(mCache != null && mCache.exists(key)) {
return mCache.loadData(key);
}
else {
// not ready yet, try to retrieve it asynchronously.
mExecutor.execute( newRequestCall(r));
return null;
}
}
示例5: ViewHolder
import android.widget.ImageView; //導入方法依賴的package包/類
ViewHolder(View view) {
super(view);
mViewTab = (TextView) view.findViewById(R.id.tv_content);
mViewBubble = (TextView) view.findViewById(R.id.tv_bubble);
mViewDel = (ImageView) view.findViewById(R.id.iv_delete);
mViewTab.setTextColor(new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_activated},
new int[]{}
}, new int[]{0XFF24CF5F, 0XFF6A6A6A})
);
mViewTab.setActivated(true);
mViewTab.setTag(this);
mViewDel.setTag(this);
mViewDel.setOnClickListener(getDeleteItemListener());
mViewTab.setOnClickListener(getClickTabItemListener());
mViewTab.setOnTouchListener(getTouchTabItemListener());
}
示例6: notifyDataSetChanged
import android.widget.ImageView; //導入方法依賴的package包/類
public void notifyDataSetChanged() {
mIconsLayout.removeAllViews();
IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter();
int count = iconAdapter.getCount();
for (int i = 0; i < count; i++) {
ImageView view = new ImageView(getContext(), null, R.attr.actionButtonStyle);
view.setImageResource(iconAdapter.getIconResId(i));
view.setTag(i);
view.setOnClickListener(this);
mIconsLayout.addView(view, new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
if (mSelectedIndex > count) {
mSelectedIndex = count - 1;
}
setCurrentItem(mSelectedIndex);
requestLayout();
}
示例7: getView
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = getLayoutInflater().inflate(R.layout.item_image, null);
ImageView iv = (ImageView) view.findViewById(R.id.iv);
Glide.with(GridView2Activity.this)
.load(mThumbViewInfoList.get(position).getUrl())
.error(R.mipmap.ic_iamge_zhanwei)
.into(iv);
iv.setTag(R.id.iv, mThumbViewInfoList.get(position));
return view;
}
示例8: showThumb
import android.widget.ImageView; //導入方法依賴的package包/類
public void showThumb(String path, ImageView imgview, int width, int height) {
if (getVideoThumbToCache(path) == null) {
// 異步加載
imgview.setTag(path);
new MyBobAsynctack(imgview, path, width, height).execute(path);
} else {
imgview.setImageBitmap(getVideoThumbToCache(path));
}
}
示例9: createThumbnailView
import android.widget.ImageView; //導入方法依賴的package包/類
private ImageView createThumbnailView(LinearLayout.LayoutParams lp, Bitmap thumbnail) {
ImageView thumbnailView = new ImageView(context);
thumbnailView.setLayoutParams(lp);
thumbnailView.setImageBitmap(thumbnail);
thumbnailView.setTag(mListOfMedia.size() - 1);
thumbnailView.setOnClickListener(thumbnailOnClickListener);
thumbnailView.setScaleType(ImageView.ScaleType.CENTER);
return thumbnailView;
}
示例10: onActivityResult
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
paoPaoQuan.setSelection(paoPaoState);
// requestCode標示請求的標示 resultCode表示有數據
Log.d("js", requestCode + "//" + resultCode + "**" + data);
if (requestCode==4||data != null) {
int childCount = imageGrid.getChildCount();
if (childCount > 9) {
Toast.makeText(this, "最多選擇9張圖片", 1).show();
} else {
imageId++;
String fPath = null;
if (requestCode == 4) {
fPath = mCurrentPhotoPath;
}else{
Uri uri = data.getData(); // 得到Uri
if((uri!=null&&!uri.equals(""))){
fPath = StaticMethod.getImageAbsolutePath(this, uri); // 轉化為路徑
}
}
Bitmap b = BitmapFactory.decodeFile(fPath);
b = StaticMethod.getThumImg(b, 100);
ImageView image = new ImageView(this);
image.setLayoutParams(new LayoutParams(130, 130));
image.setScaleType(ScaleType.FIT_XY);
image.setId(imageId);
image.setTag(fPath);
image.setImageBitmap(b);
image.setOnClickListener(this);
imageGrid.addView(image, childCount - 1);
}
}
}
示例11: init
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* 初始化
*/
private void init() {
LinearLayout layout = new LinearLayout(getContext());
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, WheelUtils.dip2px(getContext(),
WheelConstants
.WHEEL_ITEM_HEIGHT));
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING, WheelConstants
.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING);
layout.setGravity(Gravity.CENTER);
addView(layout, layoutParams);
// 圖片
mImage = new ImageView(getContext());
mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG);
mImage.setVisibility(View.GONE);
LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN;
layout.addView(mImage, imageParams);
// 文本
mText = new TextView(getContext());
mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG);
mText.setEllipsize(TextUtils.TruncateAt.END);
mText.setSingleLine();
mText.setIncludeFontPadding(false);
mText.setGravity(Gravity.CENTER);
mText.setTextColor(Color.BLACK);
LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layout.addView(mText, textParams);
}
示例12: loadImage
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void loadImage(ImageView imageView, String imagePath, int viewWidth, int viewHeight) {
imageView.setTag(R.id.album_image_load_tag, imagePath);
Bitmap bitmap = getImageFromCache(imagePath, viewWidth, viewHeight);
if (bitmap == null) {
imageView.setImageDrawable(sPlaceHolderDrawable);
mExecutorService.execute(new LoadImageTask(this, imageView, imagePath, viewWidth, viewHeight));
} else {
BitmapHolder holder = new BitmapHolder();
holder.mImageView = imageView;
holder.mTargetPath = imagePath;
holder.mBitmap = bitmap;
getHandler().post(holder);
}
}
示例13: getView
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = getLayoutInflater().inflate(R.layout.item_image, null);
ImageView iv = (ImageView) view.findViewById(R.id.iv);
Glide.with(GridViewCustomActivity.this)
.load(mThumbViewInfoList.get(position).getUrl())
.error(R.mipmap.ic_iamge_zhanwei)
.into(iv);
iv.setTag(R.id.iv, mThumbViewInfoList.get(position));
return view;
}
示例14: setColorPreview
import android.widget.ImageView; //導入方法依賴的package包/類
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
if (colorPreview == null)
return;
this.colorPreview = colorPreview;
if (selectedColor == null)
selectedColor = 0;
int children = colorPreview.getChildCount();
if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
return;
for (int i = 0; i < children; i++) {
View childView = colorPreview.getChildAt(i);
if (!(childView instanceof LinearLayout))
continue;
LinearLayout childLayout = (LinearLayout) childView;
if (i == selectedColor) {
childLayout.setBackgroundColor(Color.WHITE);
}
ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
childImage.setClickable(true);
childImage.setTag(i);
childImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (v == null)
return;
Object tag = v.getTag();
if (tag == null || !(tag instanceof Integer))
return;
setSelectedColor((int) tag);
}
});
}
}
示例15: rightButton
import android.widget.ImageView; //導入方法依賴的package包/類
public TitleBar rightButton(final int index, int iconId){
ImageView iv = generateRightButton(iconId);
iv.setTag(index);
this.title_bar_ll_right.addView(iv);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
callback.onRightButtonClicked(index, v);
}
});
return this;
}