Android Question Coming back is always a B*tch

Cableguy

Expert
Licensed User
Longtime User
Hi guys....
Back again... I think...
Well, after the firsts hours trying to figure out why a simple code didnt work, and finaly seeing where I went wrong... I have another puzzling..."nothing happens" situation...

B4X:
'Initialize 3 Panels and 1 Label, No events
    Panel0.Initialize("")
    Panel1.Initialize("")
    Panel2.Initialize("")
    Label0.Initialize("")
  
    'Add Panels to the Calling Activity
    Activity.AddView(Panel0,0,0,100%x,100%y)
    Activity.AddView(Panel1,0,0,0,0)
    Activity.AddView(Panel2,0,0,0,0)
  
    'Re-size the Panels to obtain the desired efect
    Panel1.Width = 100%x - 10dip
    Panel1.Height = 25%y
    Panel1.Top = 30%y
    Panel1.Left = 5dip
    Panel2.Width = 60%x
    Panel2.Height = 20%y
    Panel2.Top = Panel1.Top + 20dip - Panel2.Height
    Panel2.Left = Panel1.Left + 40%x - 5dip
  
    'Set The Color and Transparency of the Background Panel
    Panel0.Color = Colors.ARGB(180,10,10,10)
  
    'Set the Image for the Main Panel  
    SetNinePatchDrawable(Panel1,"placard")
  
    'Set the Image for the Secondary Panel
    Dim Img As Bitmap
    Img.Initialize(File.DirAssets,"Tribus.png")
    Panel2.SetBackgroundImage(Img)
  
    'Add Label to Main Panel
    Panel1.AddView(Label0,500dip,500dip,500dip,500dip)
  
    Label0.Color =Colors.ARGB(255,0,0,0)
    Label0.Width=Panel1.Width
    Label0.Height=Panel1.Height
    Label0.Left = Panel1.Left
    Label0.Top = Panel1.Top

All works according to what I have planned in my head, except for the Label...That just isnt there!
I have tried everything I could remember, even replacing it with another view, adding it to the Activity itself instead of the Panel, even giving it a black bacground color so that I could see it... No joy!!
So please, before I loose the few grey cells I still have over this... Where it the world is my label going????
 

Cableguy

Expert
Licensed User
Longtime User
I have had them at 100dip for each value... anyway, the values setted afterwards would render the label the same size as the Parent Panel... just for testing...
Its Driving me nuts... such a basic thing and I just can't do it...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I managed to find out WHY it wasn't showing up...

My code is logical, and should have worked as is...
It's part of a sub withing a class... so I think it deals with graphics in a somewhat different way... I may be wrong on this one...
Anyway.. It all comes down to Z-Ordering The addition of the views to their resting places...
So, as I wanted the Label to rest in a Panel, I had to first add it to the panel, and only then add the panel to the Activity...
All is working... and I am still learning...

EDIT...
IMPORTANT NOTE WHEN USING 9PACTH IMAGES WELL FORMATED!!!

If you also set the image content area when creating the 9patch image, be sure to place your views within that area or they WILL NOT BE VISIBLE.
 
Last edited:
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
So, as I wanted the Label to rest in a Panel, I had to first add it to the panel, and only then add the panel to the Activity...
This is completely untrue. I usually prefer to add panels first to the activity and then add the children (to make sure the panels have a height/width).
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
This is completely untrue. I usually prefer to add panels first to the activity and then add the children (to make sure the panels have a height/width).

read my edit.... you are correct... I just left it there to keep the conversation logical
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Very simple in its looks, but giving me a run for my money!
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…