Android Question imageview click problem

tufanv

Expert
Licensed User
Longtime User
Hello

When i use dim img(16) as imageview

I cant use for example sub img(4)_click. it gives error : You cant use something ( i dont remember the exact word) in first line.

So how am i supposed to use click event for each imageview ?

TY
 

sonicmayne

Member
Licensed User
Longtime User
You can get the Sender from the sub.

For example:

B4X:
Sub img_Click
    Dim imgview As ImageView = Sender
    If imgview = img(4) Then
        'Do stuff
    End If
End Sub

Remember to initialize each ImageView first.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
You can get the Sender from the sub.

For example:

B4X:
Sub img_Click
    Dim imgview As ImageView = Sender
    If imgview = img(4) Then
        'Do stuff
    End If
End Sub

Remember to initialize each ImageView first.

I tried it now as :( I itialized all of them )

Sub img_Click
Dim imgview As ImageView = Sender
If imgview = img(0) Then
Log("circle1")
End If
End Sub

but i cant see anything at logs altough i clicked on the first circle . Am i missing stg here ?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should post your whole code how you declare, initialize and add the ImageViews, without seeing what exactly you have done it's impossible to give a concrete advice. Otherwise we must try to guess what you could have done wrong and this is not efficient.
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
Hi,

you should do something like this :

B4X:
img(0).Initialize("img")
img(0).tag = 0

then :

B4X:
Dim imgview As ImageView = Sender
If imgview.tag = 0 Then
Log("circle1")
End If
 
Upvote 0
Top