Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android viewpager set background programmatically

I would like to know how to set a ViewPager background programmatically? In xml I can manually set the background like this: android:background="@drawable/ic_launcher". I am getting a uri from a SQLite database and converting it to a Bitmap. I want to set that Bitmap as the background. Is this possible?

like image 769
Lunchbox Avatar asked Feb 12 '26 07:02

Lunchbox


1 Answers

try first convert bitmap to drawable like

Drawable d = new BitmapDrawable(getResources(),bitmapobject);

than use

 setBackgroundDrawable(d);
like image 132
Tarsem Singh Avatar answered Feb 15 '26 20:02

Tarsem Singh