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
 
You can get the Sender from the sub.

For example:

Code: Copy
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
You can get the Sender from the sub.

For example:

Code: Copy
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
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
Hi,

you should do something like this :

Code: Copy
img(0).Initialize("img")
img(0).tag = 0

then :

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