SetBackgroundImage(LoadBitmap) within a loop?

U

unba1300

Guest
Hi. I have a scrollview that I add many edittexts to within a loop and I'm adding a background for each like so...
B4X:
et.SetBackgroundImage(LoadBitmap(File.DirAssets,"etbackground.jpg"))
Is this the 'normal' way to do it? Seems odd to be loading the bitmap each time. I thought of doing it before the loop, but the edittext is initialized each time at the start of the loop in order to clear what was there before. I also don't understand the difference between .Background and .SetBackgroundImage. Thanks.
 

derez

Expert
Licensed User
Longtime User
You can set a bitmap once with the picture and then use it in the loop:
B4X:
Dim bmp As Bitmap
bmp.Initialize(File.DirAssets,"etbackground.jpg")
...
et.SetBackgroundImage(bmp)

.background sets the background drawable if this is what you want to use, .setbackgroundimage use an image to set the background.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…