Android Question How to get Image on the buttons?

Discussion in 'Android Questions' started by Juzer Hussain, Jul 25, 2015.

  1. Juzer Hussain

    Juzer Hussain Active Member Licensed 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
     
  2. Roycefer

    Roycefer Well-Known Member Licensed User

    You can insert an Image into a Button in code via the following:
    Code:
    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.
     
  3. DanteS

    DanteS Member Licensed User

    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.
     
  4. Juzer Hussain

    Juzer Hussain Active Member Licensed 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?
     
  5. Juzer Hussain

    Juzer Hussain Active Member Licensed 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 ?
     
  6. DanteS

    DanteS Member Licensed User

    No, I have never used it in B4A. I am going to try
     
Loading...