早上好 :
我的 Activity 中有一个 ImageView,我将OntOuchListner () 设置为我的 ImageView,这意味着我为我的 ImageView 实现了该接口,如下所示:
public class mapActivity extends Activity
{
//--------------------------------------
private ImageView imageView;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView = (ImageView) this.findViewById(R.id.imageView1);
AddImageViewEvents();
}
private void AddImageViewEvents() {
imageView.setOnTouchListener(new ImageView.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int action, pointerCount, i;
action = event.getAction();
pointerCount = event.getPointerCount();
switch (action) {
case MotionEvent.ACTION_DOWN:
//code here
break;
case MotionEvent.ACTION_MOVE:
//code here
break;
default:
break;
}
return true;
}
}
我想以同样的方式将 GestureDetector 设置为我的 ImageView,我不知道这是否可能。
谢谢。