嗨,现在我制作了应用程序来运行声音并更改图片,如果我按下它现在如果我按下图片,声音会运行并且振动但是如果我移动我的手指,一切都会像往常一样恢复,但问题是;它运行一次然后它不会再次运行,这是代码`public class MainActivity extends Activity { Vibrator df; // 受保护的 MotionEvent 事件;
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mp = MediaPlayer.create(this, R.raw.sh);
ImageButton m = (ImageButton)findViewById(R.id.imageButton1);
m.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
if(MotionEvent.ACTION_DOWN == arg1.getAction())
{
mp.start();
df= (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
}
else
if(MotionEvent.ACTION_UP == arg1.getAction())
{
mp.stop();
df.cancel();
}
return false;
}
});
}
`