I have a Layout used in lots of forms and pane, loaded with [container].LoadLayout. In my class i have a Sub like this:
B4X:
Public Sub LoadLayout(parent As Object,caller As Object)
mCaller=caller
If parent Is TabPane Then
Dim t As TabPane=parent
t.LoadLayout("EmployeesList","Employees")
End If
If parent Is Form Then
Dim f As Form= parent
f.RootPane.LoadLayout("EmployeesList")
End If
FillEmployeesView
End Sub
This Layout (EmployeesList) has a button that show a DirectoryChooser.
Unfotunatelly i can't find which form is in use to pass as argument in DirectoryChooser.Show.
B4X:
Sub btCSV_Click
Dim d As DirectoryChooser
d.Initialize
d.InitialDirectory=File.DirTemp
Dim dir As String
dir=d.Show(???) '<--- PROBLEM
If dir<>"" Then
'Do Something
End If
End Sub
Sub btCSV_Click
Dim d As DirectoryChooser
d.Initialize
d.InitialDirectory=File.DirTemp
Dim dir As String
Dim f As Form ' doesn't even need to be initialized <--- Solution
dir=d.Show(f) '<--- PROBLEM
If dir<>"" Then
'Do Something
End If
End Sub