开发者

Action Listener on Image View

开发者 https://www.devze.com 2023-01-08 08:36 出处:网络
How to apply action 开发者_运维问答listener on Image viewIf you are in your onCreate method, this is quite easy :

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
    } 

});
0

精彩评论

暂无评论...
验证码 换一张
取 消