我需要做一些事情,当用户点击的ImageButton
我试图创建一个静态类实现的两个 OnClickListener
和 OnTouchListener
静态类ClickListenerForScrolling实现OnClickListener,OnTouchListener有以下方法:
@覆盖
公共无效的onClick(视图v)
和
@覆盖
公共布尔onTouch(查看为arg0,MotionEvent ARG1)
这背后的整个想法是改变的图像源的的ImageButton
当用户触摸它,当用户点击这个按钮执行任务。任何人都可以给我如何做这样的提示?
imageButton.setOnTouchListener(新View.OnClickListener(){
公共无效onTouch(查看为arg0,MotionEvent ARG1){
//改变背景在这里
}
});
imageButton.setOnClickListener(新View.OnClickListener(){
公共无效的onClick(查看为arg0){
这里//行动
}
});
I need to do something when the user clicks the imageButton
I've tried to create a static class that implements both OnClickListener
and OnTouchListener
static class ClickListenerForScrolling implements OnClickListener, OnTouchListener that has the following methods:
@Override
public void onClick(View v)
and
@Override
public boolean onTouch(View arg0, MotionEvent arg1)
The whole idea behind this is to change the image source of the ImageButton
when the user touches it, and perform a task when the user clicks this button. Can anybody give me a hint on how to do so?
imageButton.setOnTouchListener(new View.OnClickListener() {
public void onTouch(View arg0, MotionEvent arg1) {
//change background here
}
});
imageButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
//action here
}
});