Android開發零點起飛(第三章)筆記-android ImageButton src programmatically
Android開發零點起飛(第三章)筆記-android ImageButton src programmatically
ImageButton flashButtonOn = (ImageButton) findViewById(R.id.flashButtonOn);
flashButtonOn.setBackgroundResource(R.drawable.on_selector);
————-
資料來源:http://stackoverflow.com/questions/14233062/imagebutton-change-programmatically
((ImageButton) view).setImageResource(R.drawable.icon2);
ImageButton btn = (ImageButton)findViewById(R.id.button1);
btn.setImageResource(R.drawable.newimage);
ImageButton btn = (ImageButton)findViewById(R.id.button1);
btn.setImageBitmap(bm);
normalImage = Drawable.createFromStream(code);
Bitmap bm = ((BitmapDrawable)normalImage).getBitmap();
ImageButton btn = (ImageButton)findViewById(R.id.button1);
btn.setImageBitmap(bm);