is correct write a PUBLIC SUB in B4XPage and in this same page do the ShowPage?
that is (code in
PaginaHVarios)
B4X:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private BHerramienta As B4XFloatTextField
Private ComboTipoMovimiento As B4XComboBox
Private ComboEstadoUso As B4XComboBox
Private txtIncidencia As B4XView
Private lblOperativa As B4XView
Private cmdFecha As B4XView
Public TipoGestionDiDeInFo As String 'Di-Disponer De-Devolver In-Incidencia Fo-Hacer Foto
End Sub
public Sub Abrir(Tipo As String )
TipoGestionDiDeInFo = Tipo
'remember, this code are INTO PaginaHVarios
B4XPages.ShowPage("PaginaHVarios")
SetTipoGestionEnCombo
End Sub
Sub ComboTipoMovimiento_SelectedIndexChanged (Index As Int)
SetTipoGestionEnCombo(Index)
End Sub
PRIVATE Sub SetTipoGestionEnCombo(Index As Int)
txtIncidencia.Visible = False
ComboEstadoUso.cmbBox.Visible = False
lblOperativa.Visible = False
Select Case Index
Case 0
Case 1 'disponer
Case 2 'devolver
Case 3 'inciddencia
txtIncidencia.Visible = True
ComboEstadoUso.cmbBox.Visible = True
lblOperativa.Visible = True
Case 4 'SOLO FOTO
End Select
End Sub
and in other pages (menu with any opciones for open same page, but with little changes).:
1 - you are using two different types as parameter (String and Int)
2 - in cases like this it is much better to use public constants
3 - the way to call SetTipoGestionEnCombo.
I would do it so:
B4X:
' The variable below only if you need to check the page state.
Private mTipoGestionDiDeInFo As String
Public Const GESTION_DISPONER As String = "Di"
Public Const GESTION_DEVOLVER As String = "De"
Public Const GESTION_INCIDENCIA As String = "In"
Public Const GESTION_HACER_FOTO As String = "Fo"
B4X:
Public Sub Abrir(Tipo As String )
mTipoGestionDiDeInFo = Tipo 'not essential, although it might be useful.
B4XPages.ShowPage("PaginaHVarios")
SetTipoGestionEnCombo(Tipo)
End Sub
B4X:
PRIVATE Sub SetTipoGestionEnCombo(Tipo As String)
txtIncidencia.Visible = False
ComboEstadoUso.cmbBox.Visible = False
lblOperativa.Visible = False
Select Tipo
Case GESTION_DISPONER
Case GESTION_DEVOLVER
Case GESTION_INCIDENCIA
Case GESTION_HACER_FOTO
In VB6.0 I was used to including logic within the form itself and I see with B4X I can use this technique much more intuitive for me, but I was afraid to start using it, since I had gotten used to the different Activities and events they were more difficult to control.
If b4A was easy before, now it is much easier. I encourage those who have not taken the step, to use this new way of doing things.