Is there a way to pass the touch event to the parent view?
-
I have a custom ViewSwitcher in which I implemented touch events so I am able to scroll through screens using the touchscreen. My layout hierarchy looks like this: <ViewSwitcher> <LinearLayout> <ListView /> </LinearLayout> <LinearLayout> <ListView /> </LinearLayout> </ViewSwitcher> Now, the problem is that the touch events are being consumed by the ListViews and I am not able to switch the views. It works fine when I don't have the ListViews. I need to be able to scroll through the views and scroll the ListView. How do I solve this? Thanks in advance!
-
Answer:
I was able to figure it out. Since my ViewSwitcher wasn't detecting the touch event, I intercepted the touch event, called the onTouchEvent and returned false. Here: @Override public boolean onInterceptTouchEvent(MotionEvent ev) { onTouchEvent(ev); return false; } By overriding the onInterceptTouchEvent, I was able to intercept the touch event in the activity. Then I called the onTouchEvent in the ViewSwitcher which handles the switching of the ListViews. And finally by returning false, it makes sure that the ViewGroup doesn't consume the event and lets me scroll my ListViews as well.
Srichand Yella at Quora Visit the source
Other answers
I had similar problem you had few days back and then I found this http://devsbuild.it/files/PRE_andevcon_mastering-the-android-touch-system.pdf . The touch event handling is wonderfully explained here. I am sure it will solve your problem.
Darshan Patil
Related Q & A:
- How to fake a touch event in the system?Best solution by stackoverflow.com
- How much does it cost for a ship to pass through the panama canal?Best solution by Yahoo! Answers
- How Do I Get A Season's Pass At Wonderland?Best solution by Yahoo! Answers
- When do you have a merlin annual pass do you still have to pay to get in?Best solution by Yahoo! Answers
- Can the disneyland summer pass be used towards a new disneyland pass?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.