4

I have a view that can be swiped to another page. It has an onClick listener, which displays a dialog box.

The problem is, swiping triggers both actions (i.e. It shows the next page and the dialog box).

How can I disable the onClick listener when swiping.

Community
  • 1
  • 1
Shyam
  • 871
  • 6
  • 15
  • 30
  • @ADR Slow down. Some of the edit that you are suggesting are frivolous: changing "I'm trying to" into "I want to" and this one is a grammatical mess: "I'm have a view, while swiping, it will displays another page." – Sam Nov 10 '12 at 18:03
  • 1
    Nice. That is of course what he wrote to this forum for was to get his grammar checked. Why not offer a suggestion to his problem instead of knit-picking his grammar? – user2045139 May 16 '16 at 19:01

2 Answers2

6

It sounds like you want to use a GestureDetector (as well), the SimpleOnGestureListener has onSingleTapConfirmed() for click events and onFling() for swipe events.

Community
  • 1
  • 1
Sam
  • 86,580
  • 20
  • 181
  • 179
2

While onClick of swipelayout put swipelayout.getSurfaceView() and while swiping it triggers only swipe action. See the code below:

holder.swipeLayout.getSurfaceView().setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        //Do your onClick stuff here..
    }
}
Matthias Seifert
  • 2,033
  • 3
  • 29
  • 41