[android-developers] Re: WebView responding to touch events
Mark, maybe you should post some code? On Thu, Feb 5, 2009 at 4:36 PM, Mark Nuetzmann mark.nuetzm...@gmail.comwrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
Mark, I think I had this problem myself and could solve it by using the following code: webView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); Hope this would help, Sergey On Sat, Feb 7, 2009 at 12:07 AM, Mariano Kamp mariano.k...@gmail.comwrote: Mark, maybe you should post some code? On Thu, Feb 5, 2009 at 4:36 PM, Mark Nuetzmann mark.nuetzm...@gmail.comwrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
Sergey, I ended up doing basically what you posted but only for the ACTION_DOWN as that seemed to handle it. Fred, I tried adding an OnClickListener but never got any callbacks. I assume that the WebView is designed to handle this internally and expects you to use the WebViewClient.shouldOverrideUrlLoading() to respond to the clicks. As to whether it happens in the emulator I am not sure. I learned a long time ago with WM not to trust emulators so I only debug on-device... Thanks for the comments guys! Mark On Feb 7, 11:28 am, Sergey Ten sergeyte...@gmail.com wrote: Mark, I think I had this problem myself and could solve it by using the following code: webView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); Hope this would help, Sergey On Sat, Feb 7, 2009 at 12:07 AM, Mariano Kamp mariano.k...@gmail.comwrote: Mark, maybe you should post some code? On Thu, Feb 5, 2009 at 4:36 PM, Mark Nuetzmann mark.nuetzm...@gmail.comwrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
Mark, I'm not sure it would work, but have you tried to just setFocusableInTouchMode(true) on the WebView object? Seems a lot easier than messing with the touch handler. Michael On Feb 7, 3:45 pm, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: Sergey, I ended up doing basically what you posted but only for the ACTION_DOWN as that seemed to handle it. Fred, I tried adding an OnClickListener but never got any callbacks. I assume that the WebView is designed to handle this internally and expects you to use the WebViewClient.shouldOverrideUrlLoading() to respond to the clicks. As to whether it happens in the emulator I am not sure. I learned a long time ago with WM not to trust emulators so I only debug on-device... Thanks for the comments guys! Mark On Feb 7, 11:28 am, Sergey Ten sergeyte...@gmail.com wrote: Mark, I think I had this problem myself and could solve it by using the following code: webView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); Hope this would help, Sergey On Sat, Feb 7, 2009 at 12:07 AM, Mariano Kamp mariano.k...@gmail.comwrote: Mark, maybe you should post some code? On Thu, Feb 5, 2009 at 4:36 PM, Mark Nuetzmann mark.nuetzm...@gmail.comwrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
Sorry, obviously you have. Nevermind. Michael On Feb 7, 8:48 pm, kolby kolbys...@gmail.com wrote: Mark, I'm not sure it would work, but have you tried to just setFocusableInTouchMode(true) on the WebView object? Seems a lot easier than messing with the touch handler. Michael On Feb 7, 3:45 pm, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: Sergey, I ended up doing basically what you posted but only for the ACTION_DOWN as that seemed to handle it. Fred, I tried adding an OnClickListener but never got any callbacks. I assume that the WebView is designed to handle this internally and expects you to use the WebViewClient.shouldOverrideUrlLoading() to respond to the clicks. As to whether it happens in the emulator I am not sure. I learned a long time ago with WM not to trust emulators so I only debug on-device... Thanks for the comments guys! Mark On Feb 7, 11:28 am, Sergey Ten sergeyte...@gmail.com wrote: Mark, I think I had this problem myself and could solve it by using the following code: webView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); Hope this would help, Sergey On Sat, Feb 7, 2009 at 12:07 AM, Mariano Kamp mariano.k...@gmail.comwrote: Mark, maybe you should post some code? On Thu, Feb 5, 2009 at 4:36 PM, Mark Nuetzmann mark.nuetzm...@gmail.comwrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
I have been looking for this information can you detail if it occurs both in emulator and/or device? On Feb 5, 9:46 am, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: I just tried adding an OnTouchListener to the webview and I get ALL the touch events. However, the links in the webview to not appear selected/focused... This seems really weird to me. Anyone have an idea why I would receive an OnTouch event for the view but the view itself does not seem to respond to those events? On Feb 5, 9:36 am, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
Mark, I think I had this problem myself and could solve it by using the following code: webView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); Hope this would help, Sergey Fred Grott(shareme) wrote: Webview would have two touch events already as you would have the onClickListener which would have touch up touch down Were you getting those two events before adding OnTouchListener? On Feb 5, 9:46 am, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: I just tried adding an OnTouchListener to the webview and I get ALL the touch events. However, the links in the webview to not appear selected/focused... This seems really weird to me. Anyone have an idea why I would receive an OnTouch event for the view but the view itself does not seem to respond to those events? On Feb 5, 9:36 am, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: WebView responding to touch events
I just tried adding an OnTouchListener to the webview and I get ALL the touch events. However, the links in the webview to not appear selected/focused... This seems really weird to me. Anyone have an idea why I would receive an OnTouch event for the view but the view itself does not seem to respond to those events? On Feb 5, 9:36 am, Mark Nuetzmann mark.nuetzm...@gmail.com wrote: I have an Activity that has a WebView that contains some simple html that allows me to display a Terms Conditions link that if touched or clicked calls another activity. My problem is unless the link in the WebView has focus (ie, the text is wrapped with that little orange focus) I cannot touch the link and have it work. If any other view on the activity has focus, touching the WebView with the link does nothing. The other Views that had focus loose focus, but the WebView does not receive focus. I have tried calling setFocusable(true) and setFocusableInTouchMode(true) but that does not do any good... I would really like to know what you have to do to get a WebView to respond to touch events without using the trackball to scroll to the view before touching it. thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---