Android Question Access button name (id) from a view

jaraiza

Active Member
Licensed User
Longtime User
Hi,

I'm trying to attach Spotlight library in a test project. But at first I thought it was going to be easier create external layouts and load them inside a Scroll View instead creating buttons dynamically.

So, I have a main scrollview (svServ) and then I load a set of buttons from another layout:

B4X:
svServ.Panel.LoadLayout("lyIcons_Serv")

I need to find the button Name to assign it to Spotlight definition:

B4X:
SLight_Cookie.Initialize(Me,"Spotlightmenu",8%y,False,True,True,[BUTTONNAME],Activity)

I've been able to find the button:

B4X:
If svServ.Panel.GetView(1) Is Button Then
       Dim tmpButton = svServ.Panel.GetView(1) As Button
End IF

But there's not a "name" property. I've used the Tag property for other value I need, and if I want to add more values I need to add a json (or something like that) there.

Isn't there any easy way to access the button name?

Thanks!
 

Cableguy

Expert
Licensed User
Longtime User
Use an array as tag. Tag supports objects if I'm not mistaken
 
Upvote 0

jaraiza

Active Member
Licensed User
Longtime User
Use an array as tag. Tag supports objects if I'm not mistaken
I've used StringFunctions library and a tag "ButtonName,Data" to split that to a List.

But I think I've crashed against a wall... To use Spotlight, I need to create a global variable for each element:

B4X:
Private SPLight01 As SpotLight
But I can't do that dynamically... I guess. :(
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I've used StringFunctions library and a tag "ButtonName,Data" to split that to a List.

You can also use / store a Map as .Tag property ..

Unsure whether that solves your current issue. ?
 
Upvote 0
Top