ImageView setImageDrawable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ImageView setImageDrawable method.

This code example shows how to use the following methods: getVisibility, setImageDrawable, setVisibility
        if (mIconView == null) {
            insertIconView(); 
        } 
 
        if (icon != null || mPreserveIconSpacing) {
            mIconView.setImageDrawable(showIcon ? icon : null);
 
            if (mIconView.getVisibility() != VISIBLE) {
                mIconView.setVisibility(VISIBLE);
            } 
        } else { 
            mIconView.setVisibility(GONE);
        } 
    } 
 
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mIconView != null && mPreserveIconSpacing) {
            // Enforce minimum icon spacing 
            ViewGroup.LayoutParams lp = getLayoutParams();
Full Snippet Info
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setImageDrawable, setImageResource, setVisibility
        if (mMobileType != null) {
            mMobileType.setImageDrawable(null);
        } 
 
        if(mAirplane != null) {
            mAirplane.setImageDrawable(null);
        } 
 
        apply(); 
    } 
 
    // Run after each indicator change. 
    private void apply() { 
        if (mWifiGroup == null) return;
 
        if (mWifiVisible) {
            mWifi.setImageResource(mWifiStrengthId);
            mWifiActivity.setImageResource(mWifiActivityId);
 
            mWifiGroup.setContentDescription(mWifiDescription);

10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getTag, setTag, getDrawable, setImageDrawable
    } 
 
    // protected for testing purposes 
    protected void loadBitmapAsynchronously(T octo, ImageView thumbImageView,
        String tempThumbnailImageFileName) {
        if (thumbImageView.getTag() != null
            && thumbImageView.getTag().equals(tempThumbnailImageFileName)) {
            return; 
        } 
 
        if (cancelPotentialWork(tempThumbnailImageFileName, thumbImageView)) {
            final BitmapWorkerTask task = new BitmapWorkerTask(thumbImageView,
                octo);
            task.fileName = tempThumbnailImageFileName;
            final AsyncDrawable asyncDrawable = new AsyncDrawable(getContext()
                .getResources(), task);
            thumbImageView.setImageDrawable(asyncDrawable);
            thumbImageView.setTag(tempThumbnailImageFileName);
            int width = Math.round(convertDpToPixel(IMG_WIDTH, getContext()));
            int height = width;

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setId, setTag, setImageDrawable, setScaleType, setVisibility
     * Sets up the status icon, creating it if necessary. 
     */ 
    public void setStatusButton(Drawable icon, int id, long appId) {
        if (icon != null) {
            if (mStatusButton == null) {
                mStatusButton = new ImageView(mContext);
                mStatusButton.setId(id);
                mStatusButton.setScaleType(ScaleType.CENTER);
                addView(mStatusButton);
            } 
            mStatusButton.setImageDrawable(icon);
            mStatusButton.setTag(appId);
            mStatusButton.setVisibility(View.VISIBLE);
        } else { 
            if (mStatusButton != null) {
                mStatusButton.setVisibility(View.GONE);
            } 
        } 
    } 
 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: clearAnimation, getAnimation, getContext, getTag, setTag
 
    ImageView view = getView();
    if (view == null)
      return; 
 
    if (!equals(view.getTag()))
      return; 
 
    view.setTag(null);
    if (result != null) {
      if (fadeIn && view.getAnimation() == null)
        view.startAnimation(AnimationUtils.loadAnimation(view.getContext(),
            android.R.anim.fade_in));
      view.setImageBitmap(result);
    } else { 
      view.setImageDrawable(null);
      view.clearAnimation();
    } 
  } 
} 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getVisibility, setImageDrawable, setVisibility
        if (mIconView == null) {
            insertIconView(); 
        } 
         
        if (icon != null || mPreserveIconSpacing) {
            mIconView.setImageDrawable(showIcon ? icon : null);
 
            if (mIconView.getVisibility() != VISIBLE) {
                mIconView.setVisibility(VISIBLE);
            } 
        } else { 
            mIconView.setVisibility(GONE);
        } 
    } 
     
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mIconView != null && mPreserveIconSpacing) {
            // Enforce minimum icon spacing 
            ViewGroup.LayoutParams lp = getLayoutParams();
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setImageDrawable, setScaleType
        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    } 
 
    public class AppsAdapter extends BaseAdapter {
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(LayoutAnimation1.this);
 
            ResolveInfo info = mApps.get(position % mApps.size());
 
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
            i.setScaleType(ImageView.ScaleType.FIT_CENTER);
            final int w = (int) (36 * getResources().getDisplayMetrics().density + 0.5f);
            i.setLayoutParams(new GridView.LayoutParams(w, w));
            return i;
        } 
 
 
        public final int getCount() { 
            return Math.min(32, mApps.size());
        } 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getTag, setTag, setImageDrawable
        if (imageView != null) {
            if (imageUrl == null) {
                // In a ListView views are reused, so we must be sure to remove the tag that could 
                // have been set to the ImageView to prevent that the wrong image is set. 
                imageView.setTag(null);
                imageView.setImageDrawable(dummyDrawable);
                return; 
            } 
            String oldImageUrl = (String) imageView.getTag();
            if (imageUrl.equals(oldImageUrl)) {
                // nothing to do 
                return; 
            } else { 
                // Set the dummy image while waiting for the actual image to be downloaded. 
                imageView.setImageDrawable(dummyDrawable);
                imageView.setTag(imageUrl);
            } 
        } 
 
        if (imageCache.containsKeyInMemory(imageUrl)) {
            // do not go through message passing, handle directly instead 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setImageDrawable, setScaleType
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i;
 
            if (convertView == null) {
                i = new ImageView(Grid1.this);
                i.setScaleType(ImageView.ScaleType.FIT_CENTER);
                i.setLayoutParams(new GridView.LayoutParams(50, 50));
            } else { 
                i = (ImageView) convertView;
            } 
 
            ResolveInfo info = mApps.get(position);
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
 
            return i;
        } 
 
 
        public final int getCount() { 
Full Snippet Info
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setImageDrawable, setScaleType
        public View getView(int position, View convertView, ViewGroup parent) {
            CheckableLayout l;
            ImageView i;
 
            if (convertView == null) {
                i = new ImageView(Grid3.this);
                i.setScaleType(ImageView.ScaleType.FIT_CENTER);
                i.setLayoutParams(new ViewGroup.LayoutParams(50, 50));
                l = new CheckableLayout(Grid3.this);
                l.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT,
                        GridView.LayoutParams.WRAP_CONTENT));
                l.addView(i);
            } else { 
                l = (CheckableLayout) convertView;
                i = (ImageView) l.getChildAt(0);
            } 
 
            ResolveInfo info = mApps.get(position);
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related ImageView setImageDrawable Questions & Answers:

Other ImageView setImageDrawable Examples

158:				// setting downloaded into image view
159:				my_image.setImageDrawable(Drawable.createFromPath(imagePath));
160:			}
161:	
162:		}

Read More

setImageDrawable Method Overview
Sets a drawable as the content of this ImageView.
See Code Examples for other Android ImageView Methods: