Android Question Unable to remove a page id from stack

toby

Well-Known Member
Licensed User
Longtime User
My test app contains 3 pages, Main page, page2 and page3. When I navigate to page3, I want to remove page2 from the stack so that the main page, not page2, would appear if I tap the back key while page3 is displayed.

The problem I'm having is Line 10 below returns False even though the stack trace shows page2 id "page 2". Could someone kindly show me what went wrong?

TIA


B4X:
Private Sub Button1_Click
    'xui.MsgboxAsync("Hello world!", "B4X")
    B4XPages.ShowPage(B4XPages.MainPage.pageid_page3)
    Dim setPageIds As B4XSet=B4XPages.GetManager.mStackOfPageIds
    Log(setPageIds)
    For Each item As String In setPageIds.AsList
        Log(item)
    Next
    
    If B4XPages.GetManager.mStackOfPageIds.Contains(B4XPages.MainPage.pageid_page2) Then
        B4XPages.GetManager.mStackOfPageIds.Remove(B4XPages.MainPage.pageid_page2) 'remove page2 from stack
    End If
    Log(setPageIds)
End Sub
 

Attachments

  • skipPage.zip
    17.2 KB · Views: 92

toby

Well-Known Member
Licensed User
Longtime User
I have to use the following code instead to avoid null reference error
B4X:
B4XPages.ClosePage(Me)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…