Android Question IconButton(s) which one was clicked

Rusty

Well-Known Member
Licensed User
Longtime User
I have installed several iconbuttons on my activity.
Each one is directed to the same "click" event. I need to determine which one was clicked. I set a Tag value that tells me which one it was, but...
When the click event fires, I do this:
B4X:
Sub icbCategory_Click
    Try
        Dim ThisIconButton As IconButton
        ThisIconButton = Sender
        Dim tg As string
        tg = ThisIconButton.tag
log("thisiconbutton " & thisiconbutton.tag)
    Catch
        Log("icbCategory_Click error " & LastException.Message)
    End Try
End Sub

It abends and logs:

I don't understand the error. Is the iconbutton not a view?
any help will be appreciated.
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
Hi Don,
The Demo program provided shows the CLICK event and it works but doesn't provide any information that I can find that is useful, through normal means.



I was trying to use your iconify library but it fails. I posted it earlier today.
It dies on the loadlayout with
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

    icfy.Initialize()
    Entypo.Initialize
    icfy.with(Entypo)
  
    FontAwesome.Initialize
    icfy.with(FontAwesome)
  
    Ionicons.Initialize
    icfy.with(Ionicons)
  
    MaterialCommunity.Initialize
    icfy.with(MaterialCommunity)
  
    Material.Initialize
    icfy.with(Material)

    Meteocons.Initialize
    icfy.with(Meteocons)

    SimpleLineIcons.Initialize
    icfy.with(SimpleLineIcons)

    Typicons.Initialize
    icfy.with(Typicons)

    Weathericons.Initialize
    icfy.with(Weathericons)
  
      
    Activity.LoadLayout("Layout1")
line 83 is the Activity.loadlayout above

Any suggestions? We can move this to another thread if you wish.
Thanks,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Same results as before.

line 71 :
B4X:
Try
        Dim ThisIconButton As IconButton
        ThisIconButton = Sender
        Dim tg As String
this is line 71 ->        tg = ThisIconButton.tag
Log("thisiconbutton " & ThisIconButton.tag)
    Catch
        Log("thisiconbutton " & LastException)
    End Try
Rusty
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
For me it works with V1.13

B4X:
Sub IconButton_Click()
    Log("Button click")
    Dim ib As IconButton = Sender
    Log(ib.Tag)   
   
End Sub
results in
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Button click
Android
Button click
BarCode
Button click
Button
Button click
BarCode
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
... my mistake.
Apparently, I had an iconbutton.jar in my main Android libraries folder and I was putting the new one in the additional libraries.
I removed the one in the main folder and now it works in the demonstration program where the iconbutton is added to the Activity.

One last question, is there a way to change the text size and gravity?
Thanks Don!
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…