关于安卓编程onTouchEvent事件 5
2个回答
展开全部
MainActivity中写了一个 TabHost 其中tab(0) 绑定的 MusicActivity , MusicActivity对应的XML文件中定义了几个layout , MusicActivity重写OnTouchListener 接口 ,不过这个函数只对MotionEvent.ACTION_DOWN有响应,对其他的Motion都没有得到 这是为什么?
@Override
public boolean onTouch(View v , MotionEvent event) {
switch (v.getId()){
case R.id.LltMyFavor:
case R.id.LltMyDownload:
case R.id.LltLocalMusic:
case R.id.LltMyRecent:
case R.id.LltMyMusicList:
int EvtNum = event.getAction();
switch (EvtNum) {
case MotionEvent.ACTION_UP:
Toast.makeText(this, "Goodbye", Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_CANCEL:
Toast.makeText(this, "Cancel", Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_MOVE:
Toast.makeText(this, "Move", Toast.LENGTH_SHORT).show();
break;
default:
break;
}
break;
}
return false;
}
@Override
public boolean onTouch(View v , MotionEvent event) {
switch (v.getId()){
case R.id.LltMyFavor:
case R.id.LltMyDownload:
case R.id.LltLocalMusic:
case R.id.LltMyRecent:
case R.id.LltMyMusicList:
int EvtNum = event.getAction();
switch (EvtNum) {
case MotionEvent.ACTION_UP:
Toast.makeText(this, "Goodbye", Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_CANCEL:
Toast.makeText(this, "Cancel", Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_MOVE:
Toast.makeText(this, "Move", Toast.LENGTH_SHORT).show();
break;
default:
break;
}
break;
}
return false;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询