webView onTouchEvent
i'm trying to catch the onTouchEvent of a WebView, in order to handle actions like
MotionEvent.ACTION_UP
, MOVE
and CANCEL
. I made a simple example but did not success, however i succed with just a View. Am i missing something?
Thanks
public class HelloWebView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new MyWebView(this));
}
private static class MyWebView extends WebView {
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
Log.w("TouchEvent","Touch" + action);
Log.w("HitResult",this.getHitTestResult().toString());
switch (action) {
case (MotionEvent.ACTION_DOWN): // Touch screen pressed
break;
case (MotionEvent.ACTION_UP): // Touch screen touch ended
break;
case (MotionEvent.ACTION_MOVE): // Contact has moved across screen
break;
case (MotionEvent.ACTION_CANCEL): // Touch event cancelled
break;
}
return super.onTouchEvent(event);
}
public MyWebView(Context context) {
super(context);
this.getSettings().setJavaScriptEnabled(true);
this.loadUrl("http://www.google.com");
}
}
}
Asked by: Blake538 | Posted: 25-01-2022
Answer 1
it is because you are using a WebView, it has already handled much of the onTouchEvent movements. I haven't got an answer right now but at least I can tell you what the problem is!
Answered by: Paul354 | Posted: 26-02-2022Similar questions
Android - Map overlay onTouchEvent / onTap howto?
I've implemented a Class that extends Overlay and also override the onTap / onTouchEvent (tried both).
Right now it seems like that event is triggered when you tap on the map regardless of position.
How can I make sure that the event is triggered only when you tap over the overlay you have added?
Thanks,
Tee
Android - Map overlay onTouchEvent / onTap howto?
I've implemented a Class that extends Overlay and also override the onTap / onTouchEvent (tried both).
Right now it seems like that event is triggered when you tap on the map regardless of position.
How can I make sure that the event is triggered only when you tap over the overlay you have added?
Thanks,
Tee
android - detect where on the screen onTouchevent happened
I've got an onTouchEvent boolean on a Surfaceview, I've got openGL objects drawn on the view and I'm wondering is there anyway to detect where on the screen the onTouch happened? e.g (x,y) co-ordinates.
android - onTouchEvent in TabActivity don't react on anything
I have TabActivity:
public class timetable extends TabActivity
{
...
@Override
public boolean onTouchEvent(MotionEvent event)
{
Toast.makeText(this, "!", Toast.LENGTH_SHORT).show();
return true;
}
...
}
but anything not happend when I move my finger on screen (push, fling, ..)
Help me!
android - onTouchEvent how to get curret view under finger
this is my code
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
LinearLayout rLinear=new LinearLayout(this);
rLinear.setId(200);
for (int c=0;c<5;c++)
{
ImageView imEdit = new ImageView(this);
imEdit.setId(300+c);
...
touch event - Android - Can't get the OnTouchEvent to fire in Activity - using MonoDroid (Need the MotionEvent from OnTouch)
Would anyone by chance have a working example of using GestureListner with Monodroid? I can't seem to successfully translate what's out on the Net using Java.
I think I am close... And I think if I can get this "OnTouchEvent" to fire, I could in turn get my GestureDetector Class' OnTouchEvent to fire, and then I would be able to get the swipe motion (or OnFling).
What do I need to do to get this event to ...
android - OnTouchEvent guidelines for a game
This is a basic problem of an inexperienced programmer. I am making a game in android application. Obviously it requires a lot of touch events. This function seems to grow very big with if/else statements. I want some guidelines on how to write an onTouchEvent method. Can someone point me to any example that has a onTouchEvent method and how is it structured well ?
Android How to register OnTouchEvent for entire Activity main content view?
I have implemented onTouchEvent(TouchEvent) on my activity. However, I would like to know what steps are required to register this as the event for the activities main Content view. I want to set the onTouchEvent for the view that covers the entire screen space of the activity. there is a setContentView() which takes a layout id. How do I register the activity as the ontouchEvent listener to the main content view. I a...
android - live wallpaper onTouchEvent
:)
I'm trying to separate the touch from the slide but I can't get it right:
- when the user slides the screen I want to get only slides
public void onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_MOVE ) {
Log.e(Logcat, "1 slide");
}
else
...
android - onTouchEvent never called MapActivity
I have an activity which extends MapActivity. But when I tap the map, the onTouchEvent never gets called. Why is this?
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d("temp", "onTouchEvent");
return true;
}
edit: I now have these 2 methods in a custum created ItemizedOverlay to catch my events.
The first one gets called when I tap an overlay. But the second (onTouc...
android - Override onTouchEvent function in GLES Renderer class?
im trying to make a simple game with Gles on android.
i've googled a lot for a solution but i couldnt find anyone mentioning how to implement ontouchevent in GLES.
here i how i implemented it so far... i know it's a silly way to do it :D but that was only way i could come up to set positionx variable free while there is no tapping
a brief summary of my Renderer Class...
public class...
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android