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

x33g5p2x  于2022-01-20 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(162)

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

ImageView.setTag介绍

暂无

代码示例

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

ImageView mChart = (ImageView) findViewById(R.id.imageview);
String URL = "http://www...anything ...";

mChart.setTag(URL);
new DownloadImageTask.execute(mChart);

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

@Override
 public View getView(int position, View convertView, ViewGroup parent) {
   if(convertView == null){
     convertView = inflater.inflate(R.layout.list_row, parent, false);
   }
   ImageView imageView = (ImageView) convertView.findViewById(R.id.videoListImage);
   imageView.setTag(new Integer(position));
   imageView.setOnClickListener(new OnClickListener() {
     @Override
     public void onClick(View view) {
       Toast.makeText(mContext, "ImageView clicked for the row = "+view.getTag().toString(), Toast.LENGTH_SHORT).show();
     }
   });
   return convertView;
 }

代码示例来源:origin: alexvasilkov/GestureViews

@Override
protected void onBindHolder(ViewHolder holder, int position) {
  Photo photo = photos.get(position);
  holder.image.setTag(R.id.tag_item, photo);
  DemoGlideHelper.loadFlickrThumb(photo, holder.image);
}

代码示例来源:origin: androidquery/androidquery

/**
 * Set the image of an ImageView.
 *
 * @param bm Bitmap
 * @return self
 * 
 * @see testImage3
 */
public T image(Bitmap bm){
  
  if(view instanceof ImageView){
    ImageView iv = (ImageView) view;
    iv.setTag(AQuery.TAG_URL, null);
    iv.setImageBitmap(bm);
  }
  
  return self();
}

代码示例来源:origin: androidquery/androidquery

/**
 * Set the image of an ImageView.
 *
 * @param drawable the drawable
 * @return self
 * 
 * @see testImage2
 * 
 */
public T image(Drawable drawable){
  
  if(view instanceof ImageView){
    ImageView iv = (ImageView) view;
    iv.setTag(AQuery.TAG_URL, null);
    iv.setImageDrawable(drawable);
  }
  
  return self();
}

代码示例来源:origin: androidquery/androidquery

/**
 * Set the image of an ImageView.
 *
 * @param resid the resource id
 * @return self
 * 
 * @see testImage1
 */
public T image(int resid){
  
  if(view instanceof ImageView){
    ImageView iv = (ImageView) view;
    iv.setTag(AQuery.TAG_URL, null);
    if(resid == 0){
      iv.setImageBitmap(null);
    }else{				
      iv.setImageResource(resid);
    }
  }
  
  return self();
}

代码示例来源:origin: mxn21/FlowingDrawer

private void bindDefaultFeedItem(int position, CellFeedViewHolder holder) {
  if (position % 2 == 0) {
    holder.ivFeedCenter.setImageResource(R.drawable.img_feed_center_1);
    holder.ivFeedBottom.setImageResource(R.drawable.img_feed_bottom_1);
  } else {
    holder.ivFeedCenter.setImageResource(R.drawable.img_feed_center_2);
    holder.ivFeedBottom.setImageResource(R.drawable.img_feed_bottom_2);
  }
  holder.btnComments.setTag(position);
  holder.btnMore.setTag(position);
  holder.ivFeedCenter.setTag(holder);
  holder.btnLike.setTag(holder);
}

代码示例来源:origin: alexvasilkov/GestureViews

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  switch (viewType) {
    case TYPE_IMAGES:
      final ImagesViewHolder holder = new ImagesViewHolder(parent);
      // Setting up click listeners and saving images positions into tags
      for (int i = 0, size = holder.images.length; i < size; i++) {
        holder.images[i].setTag(R.id.tag_item, i);
        holder.images[i].setOnClickListener(this::onImageClick);
      }
      return holder;
    case TYPE_TEXT:
      return new TextViewHolder(parent);
    default:
      throw new IllegalArgumentException();
  }
}

代码示例来源:origin: androidquery/androidquery

private void presetBitmap(String url, ImageView v){
  
  
  if(!url.equals(v.getTag(AQuery.TAG_URL)) || preset != null){			
    
    v.setTag(AQuery.TAG_URL, url);
    
    if(preset != null && !cacheAvailable(v.getContext())){
      setBitmap(url, v, preset, true);			
    }else{
      
      setBitmap(url, v, null, true);
    }
  }
  
}

代码示例来源:origin: alibaba/Tangram-Android

public void setCurrItem(int position) {
  if (mImageViews != null) {
    for (int i = 0; i < mImageViews.length; i++) {
      if (style == STYLE_DOT) {
        mImageViews[i].setImageDrawable(getGradientDrawable(position == i ? focusColor : norColor, radius));
      } else if (style == STYLE_IMG) {
        ImageView imageView = mImageViews[i];
        if (imageView.getTag(R.id.TANGRAM_BANNER_INDICATOR_POS) == null) {
          continue;
        } else {
          imageView.setTag(R.id.TANGRAM_BANNER_INDICATOR_POS, null);
          ImageUtils.doLoadImageUrl(imageView, norUrl);
        }
      }
    }
    mImageViews[currentItemPos].setTag(R.id.TANGRAM_BANNER_INDICATOR_POS, currentItemPos);
    if (style == STYLE_IMG) {
      ImageUtils.doLoadImageUrl(mImageViews[currentItemPos], focusUrl);
    }
  }
}

代码示例来源:origin: alibaba/Tangram-Android

public void setCurrItem(int position) {
  if (mImageViews != null) {
    for (int i = 0; i < mImageViews.length; i++) {
      if (style == STYLE_DOT) {
        mImageViews[i].setImageDrawable(getGradientDrawable(position == i ? focusColor : norColor, radius));
      } else if (style == STYLE_IMG){
        ImageView imageView = mImageViews[i];
        if (imageView.getTag(R.id.TANGRAM_BANNER_INDICATOR_POS) == null) {
          continue;
        } else {
          imageView.setTag(R.id.TANGRAM_BANNER_INDICATOR_POS, null);
          ImageUtils.doLoadImageUrl(imageView, norUrl);
        }
      }
    }
    mImageViews[currentItemPos].setTag(R.id.TANGRAM_BANNER_INDICATOR_POS, currentItemPos);
    if (style == STYLE_IMG) {
      ImageUtils.doLoadImageUrl(mImageViews[currentItemPos], focusUrl);
    }
  }
}

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

ImageView view = (ImageView) findViewById(R.id.someImage);
view.setOnClickListener(new OnClickListener() {
 public void onClick(View view) {
  ImageView imageView = (ImageView) view;
  assert(R.id.someImage == imageView.getId());
  Integer integer = (Integer) imageView.getTag();
  integer = integer == null ? 0 : integer;
  switch(integer) {
  case R.drawable.foo:
   imageView.setDrawableResource(R.drawable.bar);
   imageView.setTag(R.drawable.bar);
   break;
  case R.drawable.bar:
  default:
   imageView.setDrawableResource(R.drawable.foo);
   imageView.setTag(R.drawable.foo);
   break;
 }
});

代码示例来源:origin: GitLqr/LQRWeChat

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));
  }
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

private ImageView createImageView(int position, final boolean isMultiImage) {
  String url = imagesList.get(position);
  ImageView imageView = new ColorFilterImageView(getContext());
  if(isMultiImage){
    imageView.setScaleType(ScaleType.CENTER_CROP);
    imageView.setLayoutParams(position % MAX_PER_ROW_COUNT == 0 ?moreParaColumnFirst : morePara);
  }else {
    imageView.setAdjustViewBounds(true);
    imageView.setScaleType(ScaleType.CENTER_CROP);
    imageView.setMaxHeight(pxOneMaxWandH);
    imageView.setLayoutParams(onePicPara);
  }
  imageView.setTag(R.string.zone_img_position,position);
  imageView.setId(url.hashCode());
  imageView.setOnClickListener(mImageViewOnClickListener);
  ImageLoaderUtils.display(getContext(), imageView, ImageUtil.getImageUrl(url));
  return imageView;
}

代码示例来源:origin: androidquery/androidquery

/**
 * Clear a view. Applies to ImageView, WebView, and TextView.
 *
 * @return self
 */
public T clear(){
  
  if(view != null){
    
    if(view instanceof ImageView){
      ImageView iv = ((ImageView) view);
      iv.setImageBitmap(null);
      iv.setTag(AQuery.TAG_URL, null);
    }else if(view instanceof WebView){
      WebView wv = ((WebView) view);
      wv.stopLoading();
      wv.clearView();
      wv.setTag(AQuery.TAG_URL, null);
    }else if(view instanceof TextView){
      TextView tv = ((TextView) view);
      tv.setText("");
    }
    
    
  }
  
  return self();
}

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

private void processImageResponse(ImageResponse response, String graphObjectId, ImageView imageView) {
  pendingRequests.remove(graphObjectId);
  if (response.getError() != null) {
    callOnErrorListener(response.getError());
  }
  if (imageView == null) {
    // This was a pre-fetch request.
    if (response.getBitmap() != null) {
      // Is the cache too big?
      if (prefetchedPictureCache.size() >= MAX_PREFETCHED_PICTURES) {
        // Find the oldest one and remove it.
        String oldestId = prefetchedProfilePictureIds.remove(0);
        prefetchedPictureCache.remove(oldestId);
      }
      prefetchedPictureCache.put(graphObjectId, response);
    }
  } else if (graphObjectId.equals(imageView.getTag())) {
    Exception error = response.getError();
    Bitmap bitmap = response.getBitmap();
    if (error == null && bitmap != null) {
      imageView.setImageBitmap(bitmap);
      imageView.setTag(response.getRequest().getImageUri());
    }
  }
}

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

ImageResponse response = prefetchedPictureCache.get(id);
  profilePic.setImageBitmap(response.getBitmap());
  profilePic.setTag(response.getRequest().getImageUri());
} else {
  downloadProfilePicture(id, pictureURI, profilePic);

代码示例来源:origin: wangdan/AisenWeiBo

private void setUserInfo(WeiBoUser user, TextView txtName, ImageView imgPhoto, ImageView imgVerified) {
  if (user != null) {
    txtName.setText(AisenUtils.getUserScreenName(user));
    if (imgPhoto != null) {
      BitmapLoader.getInstance().display(fragment, AisenUtils.getUserPhoto(user), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
      if (fragment instanceof SearchFragment) {
        imgPhoto.setTag(user);
        imgPhoto.setOnClickListener(searchProfileOnClickListener);
      }
      else {
        bizFragment.userShow(imgPhoto, user);
      }
    }
    AisenUtils.setImageVerified(imgVerified, user);
  }
  else {
    if (imgPhoto != null) {
      imgPhoto.setImageDrawable(new ColorDrawable(Color.GRAY));
      bizFragment.userShow(imgPhoto, null);
    }
    imgVerified.setVisibility(View.GONE);
  }
}

代码示例来源:origin: androidquery/androidquery

v.setTag(AQuery.TAG_URL, url);
status = new AjaxStatus().source(AjaxStatus.MEMORY).done();
callback(url, bm, status);

代码示例来源:origin: androidquery/androidquery

iv.setTag(AQuery.TAG_URL, url);		
Common.showProgress(progress, url, false);
setBmAnimate(iv, bm, preset, fallbackId, animation, ratio, anchor, AjaxStatus.MEMORY);

相关文章

ImageView类方法