Вопрос

I have an Application, in one of myActivity i am using webView. With some type of tablets i have the problem of double touch. a touch event in My JS and other in Android. I can't remove the touch event in JS because with some tablets. i ought to implement it. So I would like to Stop the Android touch events for this Activity and it's child and not for all the application. I tried

public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) {
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = viewGroup.getChildAt(i);
        view.setEnabled(enabled);
        if (view instanceof ViewGroup) {
            enableDisableViewGroup((ViewGroup) view, enabled);
        }
    }
}
Это было полезно?

Решение

The way to ignore a touch event on a webview is quite simple, just do :

mWebView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return false; //returns true if you wan't also ignore the js touch events
    }
});

The thing is, I'm not sure the triggered event are from the webview or another view, you need to define it so you can set this same OnTouchListener on the appropriate view.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top