代码中引用res里的颜色、图片

1、imageButton userImgButton 在代码中设置图片,使用res/Drawable 里的图片

 


 

Resources res = getResources(); 
Bitmap inDrawable= BitmapFactory.decodeResource(res, R.drawable.user_img_grey);
userImgButton.setImageBitmap(inDrawable );

 

2、imageView  user_pic 在代码中设置背景颜色,使用valus/colors里的颜色:

 

int resColor = getResources().getColor(R.color.beige);
user_pic.setBackgroundColor(resColor);
posted @ 2014-04-27 10:38  伟大的臭猪猪  阅读(227)  评论(0)    收藏  举报