2014年11月19日 星期三

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


 


 













 




沒有留言:

張貼留言