Android Question how to pass Xcustomlistview value to another b4xpage

toss

Member
Licensed User
i have xcustomLisview, i want when my user clicks on it let it open another b4xpage with the value the user clicked on. i don't know if it is possible. am new to b4x
 

toby

Well-Known Member
Licensed User
Longtime User
declare a variable in anotherPage:
public myVariable as object

assign value to the variable:
Sub clv1_ItemClick (Index As Int, Value As Object)
       Dim pageAnother As pgeAnotherPage
        pageAnother.Initialize
        B4XPages.AddPage("anotherPage", pageAnother)
        pageAnother.myVariable=Value
       b4xpage.showpage("anotherPage")

End Sub
 
Upvote 0

toss

Member
Licensed User
declare a variable in anotherPage:
public myVariable as object

assign value to the variable:
Sub clv1_ItemClick (Index As Int, Value As Object)
       Dim pageAnother As pgeAnotherPage
        pageAnother.Initialize
        B4XPages.AddPage("anotherPage", pageAnother)
        pageAnother.myVariable=Value
       b4xpage.showpage("anotherPage")

End Sub
thanks for your assistance, i am still confused because it is giving me error "Unknown Member myVariable "
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
You need to declare the variable in another page. I would be better if you project a project demonstrating your problem
 
Upvote 0

toss

Member
Licensed User
You need to declare the variable in another page. I would be better if you project a project demonstrating your problem
thanks i have done that, it is now working. please how do i access the the value i have passed to another page?
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
The attached is a sample project that works the way you want.
 

Attachments

  • Project.zip
    15.6 KB · Views: 156
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
thanks i have done that, it is now working. please how do i access the the value i have passed to another page?
See the attached sample project.

pass value from mainpage to page2:
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    myPage2.clvData=Value
    B4XPages.ShowPage("page2")
End Sub
page2 shows your mainpage selection result:
Private Sub B4Xpage_Appear
    Label1.Text=clvData
End Sub
 
Upvote 0

Marvel

Active Member
Licensed User
Another option is to add and create the b4xpage you want to open in the b4xmainpage and just update variables when it's viewed
 
Upvote 0

toss

Member
Licensed User
thanks to all who assisted me, i really i appreciate. the code is now working but i am having another problem, the problem is when a user click on the customlistview it will send the value to the next page which is okay but when they navigate back the customlistview to select another record it will still be showing the first record that was selected before navigating back to clv. this is my code

Private xclv As CustomListView

Dim parser As JSONParser
parser.Initialize(Job.GetString)
Dim Rootx As List = parser.NextArray


Dim parser As JSONParser
parser.Initialize(Job.GetString)
Dim Rootx As List = parser.NextArray
For Each colroot As Map In Rootx
' Dim msg As String = colroot.Get("msg")
Dim date As String = colroot.Get("date")
' Dim rstatus As String = colroot.Get("rstatus")
Dim subject As String = colroot.Get("subject")
Dim rkey As String = colroot.Get("rkey")
Dim status As String = colroot.Get("status")
Dim total_reply As Int = colroot.Get("total_reply")




Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(100,0,0,100%x,140dip)
p.LoadLayout("support_iterms")
Lb_subject.Text= subject
Lb_date.Text = date
lbtreply.Text= total_reply
' Lb_id.Text=rkey

If status=="0" Then
Lb_status_pending.Visible=True

Else If status=="1" Then
Lb_status_read.Visible =True


End If
xclv.Add(p, rkey)

B4X:
Private Sub xclv_ItemClick (Index As Int, Value As Object)
    Dim pageAnother As support_details
    pageAnother.Initialize
   
    pageAnother.myVariable= Value
   
    B4XPages.AddPage("anotherPage", pageAnother)
   
   
    B4XPages.ShowPageAndRemovePreviousPages ("anotherPage")

    'Log(Value)
   
End Sub
               

this code below is for next page that show more details of the clicked value
Public myVariable As String
Private xclv As CustomListView

Dim parser As JSONParser
parser.Initialize(Job.GetString)
Dim Rootx As List = parser.NextArray
For Each colroot As Map In Rootx
Dim msg As String = colroot.Get("msg")
Dim date As String = colroot.Get("date")
'Dim rstatus As String = colroot.Get("rstatus")
Dim subject As String = colroot.Get("subject")
Dim r_msg As String = colroot.Get("r_msg")
'Dim rkey As String = colroot.Get("rkey")
Dim r_date As String = colroot.Get("r_date")
Dim r_admin As String = colroot.Get("r_admin")
' Dim status As String = colroot.Get("status")
' Dim total_reply As Int = colroot.Get("total_reply")


Lb_subject.Text = subject
Lb_msg.Text = msg
lbdate.Text = date


Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(100,0,0,100%x,145dip)
p.LoadLayout("support_replies_item")

Lb_rsubject.Text = r_msg
Lb_rdate.Text = r_date

If r_admin="1" Then
Lb_admin.Visible=True
End If

xclv.Add(p, "")

Next


Private Sub lb_nav_Click
Dim back_support As support
back_support.Initialize
'myVariable=""
B4XPages.AddPage("back_support", back_support)
B4XPages.ShowPageAndRemovePreviousPages ("back_support")
End Sub
 
Last edited:
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
In "page2" if you are displaying in "_create" event then it will not update next time
display in "_appear" event, the value from customlistview
 
Upvote 0

toss

Member
Licensed User
thank you the code is now working well, what i did was in the clv click event i had to replace the page name with clv value
the old code
B4X:
Private Sub xclv_ItemClick (Index As Int, Value As Object)
    Dim pageAnother As support_details
    pageAnother.Initialize
   
    pageAnother.myVariable= Value
   
    B4XPages.AddPage("anotherPage", pageAnother)
   
   
    B4XPages.ShowPageAndRemovePreviousPages ("anotherPage")

    'Log(Value)
   
End Sub

New code
B4X:
Private Sub xclv_ItemClick (Index As Int, Value As Object)
    Dim pageAnother As support_details
    pageAnother.Initialize
   
    pageAnother.myVariable= Value
   
    B4XPages.AddPage(Value, pageAnother)
   
   
    B4XPages.ShowPageAndRemovePreviousPages (Value)

    'Log(Value)
   
End Sub
[QUOTE="AnandGupta, post: 871128, member: 74079"]
In "page2" if you are displaying in "_create" event then it will not update next time
display in "_appear" event, the value from customlistview
[/QUOTE]
 
Upvote 0
Top