Android Question How to get Image on the buttons?

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi,
I dont see images in designer to choose.I searched forum it says images should be in imageList. Is this a datatype i dont see it in menu either.Am i missing any library. Pls guide me.

Thanks
 

Roycefer

Well-Known Member
Licensed User
Longtime User
You can insert an Image into a Button in code via the following:
B4X:
Dim b as Button
b.SetBackgroundImage(LoadBitmapSample(File.DirAssets, "testimage.jpg", b.Width, b.Height))
That will create an Image from down-sampling testimage.jpg in your apk's assets folder so that it has b.Width and b.Height dimensions and then set it to b's background.
 
Upvote 0

DanteS

Member
Licensed User
Longtime User
Hi,
I dont see images in designer to choose.I searched forum it says images should be in imageList. Is this a datatype i dont see it in menu either.Am i missing any library. Pls guide me.

Thanks

If you want work with the images in design time, follow this steps: At the right hand you can see the Files tab. Choose this tab and then click Add Files. Navigate to the image you want and add it to your project. Now you can see it in the Files tab and can use it in any object of the project.
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Thanks Roycefer that method is fine but I m looking for how to use ImageList i saw "x as imagelist" somewhere is it a data type?
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Thank You DanteS I added the file it is listing now can u pls tell me how to use ImageList m i missing attaching stuff ?
 
Upvote 0
Top