How to access views from a Panel

adolleschal

Member
Licensed User
Longtime User
Hi!

When I create a Panel and Load a Layout into this Panel, how do i get access to the defined Views in that Panel?

For Example i have created a Layout which holds one EditView (edtSearch), and then i load that Layout into a dynamic created Panel - how can i now change/read the Text of edtSearch?

Many thanks for your enlightment

Best regards
Andreas
 

splatt

Active Member
Licensed User
Longtime User
Hi Andreas,

Whilst you have the designer open, select Tools\Generate Members. You will get a treeview that shows all the views on your layout. Check the events (if any) that you want to use and click the Generate Members button. This will add the declarations for your views to Sub_Globals.

You can then refer to the edittext as any other view, as below:

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim edtTest As EditText 'Added by Generate Members
End Sub 
 
Sub Activity_Create(FirstTime As Boolean)
   Dim panel1 As Panel
   panel1.Initialize("")
   panel1.LoadLayout("testlayout.bal")
   activity.AddView(panel1,0,0,activity.Width,activity.Height)
 
   edtTest.Text = "Some Text"
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…