SortableTableView icon indicating copy to clipboard operation
SortableTableView copied to clipboard

TableView OnTouchListener

Open torexko opened this issue 6 years ago • 2 comments

Hi, I have a problem with the TableView. Setting a new OnTouchListener with .setOnTouchListener() doesn't seem to work properly. The overridden method onTouch never gets called. What am I missing? Is that an intended behavior? How can I register touch events on the TableView? Thank you.

torexko avatar Jan 23 '18 14:01 torexko

Hi @torexko,

it was not intended to use the OnTouchListener at all. What are you trying to achieve? Why do you need to listen for OnTouchEvents?

Best regards, Ingo

ISchwarz23 avatar Jan 30 '18 16:01 ISchwarz23

Because there is another View interfering with touch events and I can't scroll the TableView. I had the same problem with a ListView inside a ScrollView and I was able to make it work using this piece of code:

        listView.setOnTouchListener(new ListView.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int action = event.getAction();
                switch (action) {
                    case MotionEvent.ACTION_DOWN:
                        // Disallow ScrollView to intercept touch events.
                        v.getParent().requestDisallowInterceptTouchEvent(true);
                        break;

                    case MotionEvent.ACTION_UP:
                        // Allow ScrollView to intercept touch events.
                        v.getParent().requestDisallowInterceptTouchEvent(false);
                        break;
                }

                // Handle ListView touch events.
                v.onTouchEvent(event);
                return true;
            }
        });

torexko avatar Jan 31 '18 14:01 torexko