只要触摸屏幕,我就想在 ImageView 中设置名为“pic”的图像。我是初学者,不知道 MotionEvent 的代码应该是什么,有人可以帮我解决这个问题。这是我的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.frame);
fl = (FrameLayout)findViewById(R.id.titlescreenframe);
screen=(ImageView)findViewById(R.id.imageView1);
fl.setOnTouchListener(new View.OnTouchListener() {
@Override public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
//WHAT CODE SHOULD BE HERE
break;
case MotionEvent.ACTION_UP:
//WHAT CODE SHOULD BE HERE
break;
}
return false;
}
Runnable mAction = new Runnable() {
@Override public void run() {
screen.setImageResource(R.drawable.pic);
}
};
});
}
}