Android Question ShowPage in B4X with public function into Page. Is Correct?

netsistemas

Active Member
Licensed User
Longtime User
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).:



B4X:
    B4XPages.MainPage.PaginaHVarios.Abrir( TipoGestionDiDeInFo)


and a PUBLIC PAGE in B4XMainPage

B4X:
    Public PaginaHVarios As PageHVarios

It this is correct, this b4x is the event, sorry: heaven
great!!!
 

LucaMs

Expert
Licensed User
Longtime User
Yes, it can be a way. Just a few things:

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


From other pages:
B4X:
B4XPages.MainPage.PaginaHVarios.Abrir(B4XPages.MainPage.PaginaHVarios.GESTION_INCIDENCIA)
 
Last edited:
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
Perfect!! Thank you.

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.
 
Upvote 0
Top