0

In my app I use two external libraries (Sliding menu and Horizontal Listview). The first one implements a sliding menu effect like the Facebook app and it works fine, I can trigger the movement by swiping or clicking a button. The second one implements an horizontal listview which I can scroll swiping right/left. Using both of them I can see the listview but the scroll movement doesn't work. How can I solve it? I guess the menu is "stealing" the swipe action.

If you need some code just ask.

EDIT: Actually it works! I just have to put the finger on the horizontal view and swipe a little bit up/down and then I can swipe left/right. Which could be tha cause of this behaviour?

phcaze
  • 1,707
  • 5
  • 27
  • 58

1 Answers1

2

There is very simple solution! Just set OnTouchListener for your HorizontalListView, disable slinding menu on ACTION_DOWN and reenable it on ACTION_UP.

getActivity().findViewById(R.id.my_horizontal_list_view).setOnTouchListener(

    new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                ((SlidingFragmentActivity) getActivity()).getSlidingMenu().setSlidingEnabled(false);
            }

            if (event.getAction() == MotionEvent.ACTION_UP) {
                ((SlidingFragmentActivity) getActivity()).getSlidingMenu().setSlidingEnabled(true);
            }

            return false;
        }
    }
);
gingo
  • 3,149
  • 1
  • 23
  • 32