tags:

views:

38

answers:

2

Hi, I'm kind of new to this whole thing so I need some help. I have an application that creates an ImageView OnCreate. I want to make this image clickable and have it open a browser to a specific link.

How would I do this? I'm having trouble specifically with the setOnClickListener because the parameters are not accepting an OnClickListener.

I'm developing for Android 1.6

A: 

You shoud set ImageView property clickable to true. Then set listener:

mImageView.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View view) {
    // do stuff
  }

});
Rabas
Thanks! Worked like a charm. For some reason the code I was using before had invalid parameters.
Hunter
A: 

You can subclass ImageView, if you like. Then you can override onClick in your own class. Rabas' method is probably more common though, and seen throughout Google's examples.

Maximus