Android開發零點起飛(第三章)筆記-android ImageButton src programmatically

Android開發零點起飛(第三章)筆記-android ImageButton src programmatically

Android開發零點起飛(第三章)筆記-android ImageButton src programmatically

 

 

資料來源:http://stackoverflow.com/questions/17129589/how-do-i-programmatically-change-the-imagebutton-src-target-when-a-condition-is

 

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);

 

————-
資料來源:http://stackoverflow.com/questions/7346864/implement-androidsrc-drawable-image-programatically-in-android

 

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);

 

 

 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *