ImageView setImageResource - 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 setImageResource method.

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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setImageResource, setScaleType
        return position;
    } 
 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView i = new ImageView(mContext);
        i.setImageResource(mImageIds[position]);
        i.setScaleType(ScaleType.CENTER_INSIDE);
        return i;
    } 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackgroundResource, setLayoutParams, setImageResource, setScaleType
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {
                convertView = new ImageView(mContext);
 
                imageView = (ImageView) convertView;
                imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                imageView.setLayoutParams(new Gallery.LayoutParams(
                        (int) (ITEM_WIDTH * mDensity + 0.5f),
                        (int) (ITEM_HEIGHT * mDensity + 0.5f)));
             
                // The preferred Gallery item background 
                imageView.setBackgroundResource(mGalleryItemBackground);
            } else { 
                imageView = (ImageView) convertView;
            } 
 
            imageView.setImageResource(mImageIds[position]);

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setPadding, setAdjustViewBounds, setImageResource, setScaleType
This code example shows how to use the following methods:setBackgroundResource, setLayoutParams, setAdjustViewBounds, setImageResource
        public long getItemId(int position) {
            return position;
        } 
 
        public View getView(final int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);
 
            i.setImageResource(THUMB_IDS[position]);
            i.setAdjustViewBounds(true);
            i.setLayoutParams(new Gallery.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            i.setBackgroundResource(android.R.drawable.picture_frame);
            return i;
        } 
 
    } 
 
} 
 
     
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setImageResource, setScaleType
		return index;
	} 
 
	@Override 
	public View getView(int postion, View view, ViewGroup group) {
		ImageView imageView = new ImageView(_context);
		imageView.setImageResource(imageIds[postion]);
		imageView.setScaleType(ScaleType.FIT_XY);
		imageView.setLayoutParams(new Gallery.LayoutParams(400, 400));
		return imageView;
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setBackgroundColor, setImageResource, setScaleType
     * Display the thumbnail from a resource. 
     * 
     * @param resId Resource ID of the drawable to show. 
     */ 
    public void displayThumbnail(int resId) {
        mThumbnailView.setScaleType(ScaleType.CENTER);
        mThumbnailView.setImageResource(resId);
        mThumbnailView.setBackgroundColor(0x0);
    } 
 
    /** 
     * Display the thumbnail from a bitmap. 
     * 
     * @param thumbnail The bitmap to show as thumbnail. 
     */ 
    public void displayThumbnail(Bitmap thumbnail) {
        if (thumbnail == null) {
            // Show a favicon based view instead. 
            displayThumbnail(R.drawable.favicon); 
            return; 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setPadding, setImageResource, setScaleType
 
	    // create a new ImageView for each item referenced by the Adapter 
	    public View getView(int position, View convertView, ViewGroup parent) {
	        ImageView imageView;
	        if (convertView == null) {  // if it's not recycled, initialize some attributes
	            imageView = new ImageView(mContext);
	            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
	            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
	            imageView.setPadding(8, 8, 8, 8);
	        } else { 
	            imageView = (ImageView) convertView;
	        } 
 
	        imageView.setImageResource(mThumbIds[position]);
	        return imageView;
	    } 
 
	    // references to our images 
	    private Integer[] mThumbIds = {
	            R.drawable.happy_plant, R.drawable.cold_plant, 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setMinimumHeight, setMinimumWidth, setImageResource, setScaleType
 
    protected void populateMenu() { 
    } 
 
    protected PieItem makeItem(int image, int l) {
        ImageView view = new ImageView(mActivity);
        view.setImageResource(image);
        view.setMinimumWidth(mItemSize);
        view.setMinimumHeight(mItemSize);
        view.setScaleType(ScaleType.CENTER);
        LayoutParams lp = new LayoutParams(mItemSize, mItemSize);
        view.setLayoutParams(lp);
        return new PieItem(view, l);
    } 
 
    protected PieItem makeFiller() { 
        return new PieItem(null, 1); 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setOnClickListener, setImageResource
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
         
        RelativeLayout container = new RelativeLayout(this);
         
        ImageButton button = new ImageButton(this);
        button.setImageResource(getIntent().getIntExtra("moodimg", 0));
        button.setOnClickListener(this);
         
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
         
        container.addView(button, lp);
         
        setContentView(container);
    } 
 
    public void onClick(View v) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related ImageView setImageResource Questions & Answers:

Other ImageView setImageResource Examples

51:	        TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
52:	         
53:	        imgIcon.setImageResource(navDrawerItems.get(position).getIcon());        
54:	        txtTitle.setText(navDrawerItems.get(position).getTitle());
55:

Read More

43:	        {
44:	            queuePhoto(url, imageView);
45:	            imageView.setImageResource(loader);
46:	        }
47:	    }

Read More

53:	        txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
54:	        
55:	        imgIcon.setImageResource(spinnerNavItem.get(position).getIcon());
56:	        imgIcon.setVisibility(View.GONE);
57:	        txtTitle.setText(spinnerNavItem.get(position).getTitle());
-
71:	        txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);
72:	        
73:	        imgIcon.setImageResource(spinnerNavItem.get(position).getIcon());        
74:	        txtTitle.setText(spinnerNavItem.get(position).getTitle());
75:	        return convertView;

Read More

30:	        }
31:	
32:	        imageView.setImageResource(mThumbIds[position]);
33:	        return imageView;
34:	    }

Read More

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