Android Question Floating windows class backgroud

Discussion in 'Android Questions' started by juniorteacher, Jul 3, 2015.

  1. juniorteacher

    juniorteacher Member Licensed User

    how to set background in floating windows class?

    Code:
    Sub Globals
    dim drag1 As ClsFloatingWindow
    dim panel1 as panel
    end sub

    Sub Activity_Create(FirstTime As Boolean)
      
    Activity.LoadLayout("game3")
       drag1.Initialize(Panel1, 
    5%x40%y30%x10%y, Me)
       drag1.EnableTitleBar(
    False)
       drag1.SetBackground(
    LoadBitmap(File.DirAssets,"g3 soal1 0.png")) ' getting error in here
    end sub
     
  2. Informatix

    Informatix Expert Licensed User

    As said by the function help text: Background = a valid drawable
    Code:
    Dim bmpD As BitmapDrawable
    bmpD.Initialize(
    LoadBitmap...)
    drag1.SetBackground(bmpD)
    or simpler, with AsPanel:
    Code:
    drag1.AsPanel.SetBackgroundImage(LoadBitmap...)
     
    Last edited: Jul 3, 2015
    lemonisdead and juniorteacher like this.
  3. LucaMs

    LucaMs Expert Licensed User

    Try so:
    Code:
    Sub Activity_Create(FirstTime As Boolean)
      
    Activity.LoadLayout("game3")
       drag1.Initialize(Panel1, 
    5%x40%y30%x10%y, Me)
       drag1.EnableTitleBar(
    False)
       
    Dim BD As BitmapDrawable = LoadBitmap(File.DirAssets,"g3 soal1 0.png")
       drag1.SetBackground(BD) 
    ' getting error in here
    end sub
     
    juniorteacher likes this.
  4. juniorteacher

    juniorteacher Member Licensed User

    thanks for the answer...
    getting error because i don't know what meaning this :
    Background = a valid drawable
     
  5. LucaMs

    LucaMs Expert Licensed User

  6. juniorteacher

    juniorteacher Member Licensed User

    the images didn't show
    but no error message
    why?
     
  7. Informatix

    Informatix Expert Licensed User

    Without a project to test, it's hard to say.
     
  8. juniorteacher

    juniorteacher Member Licensed User

    this my project
     

    Attached Files:

  9. Informatix

    Informatix Expert Licensed User

    That should not even compile. For the same reason as the initial post: a bitmap is not a drawable.
     
  10. Informatix

    Informatix Expert Licensed User

    Using AsPanel does not seem to work, so use the first solution that I gave. It works.
     
    juniorteacher likes this.
  11. juniorteacher

    juniorteacher Member Licensed User

  12. LucaMs

    LucaMs Expert Licensed User

    You are right, it should be:

    Dim BD As BitmapDrawable
    BD.Initialize(LoadBitmap(File.DirAssets, "MyImage.png"))
     
  13. LucaMs

    LucaMs Expert Licensed User

    Code:
    Sub Activity_Create(FirstTime As Boolean)
      
    Activity.LoadLayout("game3")
       drag1.Initialize(Panel1, 
    5%x40%y30%x10%y, Me)
       drag1.EnableTitleBar(
    False)
       
    Dim BD As BitmapDrawable
       BD.Initialize(
    LoadBitmap(File.DirAssets, "g3 soal1 0.png"))
       drag1.SetBackground(BD) 
    ' getting error in here
    end sub
     
    lemonisdead likes this.
Loading...