Pass information between the activities using multiple buttons

devjet

Member
Licensed User
Longtime User
Hello,
probably a no brainer for most of you....

I have just been reading this article and checked out the sample.http://www.b4x.com/forum/basic4andr...ls/6611-two-activities-example.html#post38609

How can I apply this if I use a set of multiple buttons on Activity 1?

Activity 1 has 10 buttons (each represents a hard coded URL)
Activity 2 there is a web View ( which should show the respective info of above URL of pressed button. As the buttons are individual controls I can not apply the list view sample

Thanks for any hint!
 

kickaha

Well-Known Member
Licensed User
Longtime User
If the buttons are in the "main" activity:

Dim a string in the Sub Process_Globals of the main activity to hold the url for example
B4X:
Dim MyUrl As String
in the button event for each button set MyUrl to the Url you want, and start the second activity.

In the second activity, you can get the Url with main.MyUrl, so you can use
B4X:
WebView.LoadUrl (main.MyUrl)

This can be further simplified by setting the event for all the buttons to be the same, and putting the url in the tag. The Click event for the buttons would then be
B4X:
Dim btn As Button
btn = Sender
MyUrl=btn.Tag 
StartActivity (second activity)
 
Upvote 0
Top