Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set bitmap image to Button Background Image

gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);    
gridcell.setText("Day 1");    
URL url = new URL("http://172.16.4.29:81/pht/2013/9/18/3027_2013_9_18_12_14_56_b.JPG");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());

How can I set bitmap bmp image to button gridcells background Image?

like image 243
Viresh Avatar asked Sep 23 '13 06:09

Viresh


1 Answers

You can use following code to do that..

BitmapDrawable bdrawable = new BitmapDrawable(context.getResources(),bitmap);

then just set bitmap with below function

button.setBackground(bdrawable);
like image 54
Chintan Rathod Avatar answered Sep 30 '22 20:09

Chintan Rathod