Android Question Update (redraw) B4XPage

Arquero

Member
In a B4XPages application, I update the text of a menu item in runtime.
However, this change isn't visible until I load another page and return to the original were the text was changed.
I've tried calling B4XPage_Appear after the change, but only my code is executed, not the "parent" code, so it doesn't work. I know this because the log doesn't show "*** mainpage: B4XPage_Appear". How can I trigger this kind of full refresh? Recreate the whole Mainpage will be "to use a sledgehammer to crack a nut"...

PS: It's similar to this:

https://www.b4x.com/android/forum/threads/open-and-close-b4xpage.167900/#post-1029265

But I've tried the ideas you suggested there without success.

The point is the menu item act as a switch, and the text changes "enabled/disabled". I dont wanna use Appcompat only for that.
 

Jerryk

Active Member
Licensed User
Longtime User
I don't know if I understood you - do you need to change data from one page to another? I do it like this:

Code from the called page
B4X:
Dim PageS As pStat = B4XPages.GetPage("page_Stat")
PageS.refresh = True

Code in the called page
B4X:
Public refresh = False As Boolean

Private Sub B4XPage_Appear
    If refresh = True Then
        ..... your code
        refresh = False
End Sub
 
Upvote 0

Arquero

Member
No, I need to trigger a full refresh of views. Try to explain more.
I have a B4XPages app, in Mainpage I have a menu build like this:
B4X:
Sub Class_Globals
    ...
    Private modomenu As B4AMenuItem   
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Resumen")
    modomenu = B4XPages.AddMenuItem(Me, "Enabled")
    B4XPages.AddMenuItem(Me, "Another item")
    ...
End Sub

Private Sub B4XPage_Appear
    Log("MyAppear")
    ...
End Sub

Private Sub B4XPage_MenuClick (Tag As String)
    If Tag = "Enabled" Then
        modomenu.Title = "Disabled"
        ...
        B4XPage_Appear 'Don't trigger full refresh, so don't work for my purpose
    End If
    ...
End Sub

After I press enabled option in the menu, it collapsed and the setting is set. But if I click the menu again, it still has the word "Enabled"...
But if then I load another page and just after load that new page I press back to close it and return to main. The menu now displays "Disabled".

Thats why when Mainpage shows again another kind of Appear is trigger (I guess an appear sub in parent class maybe), that appear sub, the good one, log: "*** mainpage: B4XPage_Appear", but when I call B4XPage_Appear that entry log is not shown only its logged: "MyAppear".

In C# you can call parent function from child like this:
C#:
public class Child : Parent
{
    public void LoadData()
    {
        base.MyMethod(); // call method of parent class
        // other stuff...
    }
}

Here I don't know how to call the Appear function that log "*** mainpage: B4XPage_Appear", or, in case, how to trigger a menu entries refresh.
 
Upvote 0

Arquero

Member
Well If I do:
B4X:
Private Sub B4XPage_MenuClick (Tag As String)
    If Tag = "Enabled" Then
        modomenu.Title = "Disabled"
        B4XPages.ShowPageAndRemovePreviousPages("MainPage")
    End If
    ...
do the trick...

The screen flicks and I don't now if there are betters ways but menu caption changes... Anyway if somebody have a better way please feel free to teach me. Thanks in advance!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…