Android Question B4XPages Question

Almora

Well-Known Member
Licensed User
Longtime User
Activity

activity1:
Dim a1 As Int

Private Sub Amir_onItemClick (Parent As Panel,Position As Int)
     a1=Position
    StartActivity(activity2)   
End Sub

activity2:
Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("layot1")

    If activity1.a1=0 Then
        MsgboxAsync("xxx", "info")

    Else If activity1.a1=1 Then
        MsgboxAsync("yyy", "info")
          
    End If
End Sub


I want to convert my application to b4page.
what is the b4x pages equivalent of the above code.
the code below fails. it shows "xxx" continuously.
thanks..


B4xpage

activity1:
Dim a1 As Int

Private Sub Amir_onItemClick (Parent As Panel,Position As Int)
    a1=Position
  
    B4XPages.ShowPage("activity2")
  
End Sub

activity2:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("layot1")
  
    If B4XPages.MainPage.activity1.a1=0 Then
         MsgboxAsync("xxx", "info")
      
    Else If B4XPages.MainPage.activity1.a1=1 Then
         MsgboxAsync("yyy", "info")
    End If
  
    End sub
 
Last edited:

Almora

Well-Known Member
Licensed User
Longtime User
B4XPages.MainPage.activity1.a1=0
What is this?
It would be easier to help you, at least for me, if you posted a small project showing the problem.
Just with code snippets it is difficult to help.

I added a small project. The project I want to convert is test1.
 

Attachments

  • test1.zip
    10.7 KB · Views: 128
  • testB4xpage.zip
    11.5 KB · Views: 127
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
These projects will help me.
I have listview instead of Amir_RecyclerView .
thanks..
 

Attachments

  • test2.zip
    10.7 KB · Views: 156
  • test2B4xpage.zip
    11.6 KB · Views: 120
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should create the B4XPage_Appear event routine and move NetWork there.
As the comment says, B4XPage_Created is called only once when the page is created.
B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    
'    Network
End Sub

Private Sub B4XPage_Appear
    Network
End Sub

To generate a zip file for a B4XPages project you should use this line on top of the code in B4XMainPage.

1611439346501.png

I had to comment line #2 to make the program run because of the missing Shared Files folder.
 
Upvote 0
Top