Action Listener on Image View
How to apply action 开发者_运维问答listener on Image view
If you are in your onCreate method, this is quite easy :
//create you ImageView :
ImageView iv = (ImageView) findViewById(R.id.itsId);
//set the listener
iv.setOnClickListener(this);
Then let your activity implement OnClickListener
and add unimplemented method. finally, add the behaviour you need in the onClick()
method
Type this inside onCreate() :
ImageView image = (ImageView) findViewById(R.id.imageid);
image.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
//actions
}
});
精彩评论