私のプロジェクトでは、画面上のタッチを検出し、それに応じてアクションを実行するために onTouchEvent を使用し、スワイプアクションに viewPager を使用しました。問題は、タッチアクションが実行されているスワイプにあります。ここから解決策を見つけて解決しました。しかし、私の新しい問題は、 TouchEvent.Action_up が実行されると、タッチが無効になることです。コードは次のとおりです。
parent.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction())
{
case MotionEvent.ACTION_MOVE:
awesomePager.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
awesomePager.requestDisallowInterceptTouchEvent(true);
if(flag)
{
upperdock.setClickable(false);
upperdock.bringToFront();
tocparent.bringToFront();
tocbottom.bringToFront();
upperdock.setVisibility(RelativeLayout.VISIBLE);
tocparent.setVisibility(LinearLayout.VISIBLE);
tocbottom.setVisibility(LinearLayout.VISIBLE);
flag=false;
}
else
{
parent.bringToFront();
upperdock.setVisibility(RelativeLayout.INVISIBLE);
tocparent.setVisibility(LinearLayout.INVISIBLE);
tocbottom.setVisibility(LinearLayout.INVISIBLE);
flag=true;
}
break;
case MotionEvent.ACTION_CANCEL:
awesomePager.requestDisallowInterceptTouchEvent(false);
break;
default:
break;
}
return false;
}
});
上記のコードで、false を返すと Action_up が実行されません。true を返すと、Action_cancel が実行されません。つまり、値渡しが問題です。