Android Question Show page from B4XMainPage

quansofts

Member
Hi All,
  • In the B4XMainPage, I want to show the Logon_Page for user to logon but the layout of logon_page was not loaded just empty Logon_Page was showed, how to solve this?
  • Where is the bets appropriate module to declare global variables Stater or B4XMainPage?
Thanks for any help

B4XMainPage:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    B4XPages.SetTitle(Me,"Home")
    
    ' Init pages and add pages to B4XPages collection
    StartPage.Initialize
    B4XPages.AddPage("Start_Page",StartPage)
    
    CustomerPage.Initialize
    B4XPages.AddPage("Customer_Page",CustomerPage)
    
    LogonPage.Initialize
    B4XPages.AddPage("Logon_Page",LogonPage)
    
    ' Show logon page
    B4XPages.ShowPageAndRemovePreviousPages("Logon_Page")
End Sub
 

TILogistic

Expert
Licensed User
Longtime User
see simple login B4X:

1631909902750.png
1631910057175.png
 

Attachments

  • B4XLogin.zip
    18.1 KB · Views: 182
Upvote 1

edgar_ortiz

Active Member
Licensed User
Longtime User
Hi Oparra

I was reviewing your example and I am left wondering:
How does "the click of the button" work?

If the button is not defined

B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore

    Private txtUserName As B4XFloatTextField
    Private txtUserPaword As B4XFloatTextField
End Sub

B4X:
Private Sub btnLogin_Click
    'Return MainPage
    If txtUserName.Text = "" Then
        xui.MsgboxAsync("Enter user name", "Warning")
        Return
    End If
    If txtUserPaword.Text = "" Then
        xui.MsgboxAsync("Enter password", "Warning")
        Return
    End If
    B4XPages.ShowPageAndRemovePreviousPages("MainPage")
End Sub

Regards,

Edgar
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The way I have understood it, as long as the button is in the designer, you do not need to declare the button in the Class_Globals if you use it for the click event. For anything else, you need to declare it.
 
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
Hi Oparra

I was reviewing your example and I am left wondering:
How does "the click of the button" work?

If the button is not defined

B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore

    Private txtUserName As B4XFloatTextField
    Private txtUserPaword As B4XFloatTextField
End Sub

B4X:
Private Sub btnLogin_Click
    'Return MainPage
    If txtUserName.Text = "" Then
        xui.MsgboxAsync("Enter user name", "Warning")
        Return
    End If
    If txtUserPaword.Text = "" Then
        xui.MsgboxAsync("Enter password", "Warning")
        Return
    End If
    B4XPages.ShowPageAndRemovePreviousPages("MainPage")
End Sub

Regards,

Edgar
When you only want to use the events, it is not necessary to define the button, it is already explicit when you load the design (layout)

You only define it when you want to change its properties.
 
Upvote 1
Top