2

I have list view with. User can open dialog on full screen Window.FEATURE_NO_TITLE) that overlay this list view. When user touches the background of this dialog it closes.

I need to delegate this touch event to list view. I mean, after MotionEvent.ACTION_DOWN on bg i need to close dialog (it works fine), and start MotionEvent.ACTION_DOWN on list view.

I tried something like this:

((LinearLayout) findViewById(R.id.dialog_bg)).setOnTouchListener(new    View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        MotionEvent motionEvent = MotionEvent.obtain(event);                          
                        activity.findViewById(R.id.fr_projects_list).dispatchTouchEvent(motionEvent);
                        close();

                        break;

                    default:
                        break;
                }

                return false;
            }
        });

It starts ACTION_DOWN on list view. But thats all. ACTION_MOVE and others doesn't work =/

1 Answers1

1

You are dispatching only ACTION_DOWN that's why you are not getting any other actions. Try dispatching all actions.

((LinearLayout) findViewById(R.id.dialog_bg)).setOnTouchListener(new    View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
                    MotionEvent motionEvent = MotionEvent.obtain(event);                          
                    activity.findViewById(R.id.fr_projects_list).dispatchTouchEvent(motionEvent);
                    if(event.getAtction==MotinEvent.ACTION_UP) close();
                    return false;
        }
    });
Praveena
  • 6,340
  • 2
  • 40
  • 53