設置ImageView的src:code
image.setImageDrawable(getResources().getDrawable(R.drawable.blackk)); String path=Environment.getExternalStorageDirectory()+File.separator+」test.jpg」; Bitmap bm = BitmapFactory.decodeFile(path); image.setImageBitmap(bm); image.setImageResource(R.drawable.blackk);
設置ImageView的background:get
image.setBackground(getResources().getDrawable(R.drawable.blackk)); image.setBackgroundResource(R.drawable.blackk); image.setBackgroundDrawable(getResources().getDrawable(R.drawable.blackk));