rfresh Well-Known Member Licensed User Longtime User Feb 24, 2012 #1 I'm getting an object (LabeL) should first be initialized error on my Label with the following code to center a Label: PHP: Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Main") Dim lbl_cb2 As Label lbl_cb2.Left = Activity.width - lbl_cb2.width / 2 End Sub Also am I accessing the screen width correct using Activity.width? Thanks...
I'm getting an object (LabeL) should first be initialized error on my Label with the following code to center a Label: PHP: Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Main") Dim lbl_cb2 As Label lbl_cb2.Left = Activity.width - lbl_cb2.width / 2 End Sub Also am I accessing the screen width correct using Activity.width? Thanks...
NJDude Expert Licensed User Longtime User Feb 24, 2012 #2 It should be: B4X: lbl_cb2.Left = (Activity.width - lbl_cb2.width) / 2 And this line should be in Sub Globals B4X: Dim lbl_cb2 As Label Last edited: Feb 24, 2012 Upvote 0
It should be: B4X: lbl_cb2.Left = (Activity.width - lbl_cb2.width) / 2 And this line should be in Sub Globals B4X: Dim lbl_cb2 As Label
A admac231 Active Member Licensed User Longtime User Feb 24, 2012 #3 Bear in mind you should also centre the label either in the designer or by using B4X: lbl_cb2.Gravity = Gravity.CENTER Upvote 0
Bear in mind you should also centre the label either in the designer or by using B4X: lbl_cb2.Gravity = Gravity.CENTER