Android Question imageview click problem

Discussion in 'Android Questions' started by tufanv, Jul 4, 2015.

  1. tufanv

    tufanv Expert Licensed 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
     
  2. sonicmayne

    sonicmayne Member Licensed User

    You can get the Sender from the sub.

    For example:

    Code:
    Sub img_Click
        
    Dim imgview As ImageView = Sender
        
    If imgview = img(4Then
            
    'Do stuff
        End If
    End Sub
    Remember to initialize each ImageView first.
     
    tufanv likes this.
  3. tufanv

    tufanv Expert Licensed User

    Thank you !
     
    sonicmayne likes this.
  4. tufanv

    tufanv Expert Licensed User

    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 ?
     
  5. sonicmayne

    sonicmayne Member Licensed User

    Is the event name for each set to img?

    For example:
    Code:
    img(0).Initialize("img")
     
    tufanv likes this.
  6. klaus

    klaus Expert Licensed 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.
     
  7. tufanv

    tufanv Expert Licensed User

    Yeah that was the problem. I initailiaized all the views with the same event name and it is now working . Thanks
     
    sonicmayne likes this.
  8. Ohanian

    Ohanian Active Member Licensed User

    Hi,

    you should do something like this :

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

    Code:
    Dim imgview As ImageView = Sender
    If imgview.tag = 0 Then
    Log("circle1")
    End If
     
Loading...