开发者

onItemClickListener into GridView don't catch click events when displayed WebView components

I need to displayed WebView components into GridView. The problem is that on android 2.3.x the onItemClickListener don't catch the click events. It's ok on android 2.2.x . The problem for me depend by webvie开发者_如何学Gow function isInTouchMode() that return always TRUE on android 2.3 and return false on android 2.2. I think that the solution is set to false this parameter, but i don't know how!! There is anyone that can help me please? Thanks


I have using following code:

public class GifView extends WebView {

    /**
     * @param context
     * @param attrs
     */
    public GifView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setClickable(false);
        setFocusable(false);
        setFocusableInTouchMode(false);
        setLongClickable(false);

    }

    // actions

}


Resolved: I've created MyWebView object that extends WebView and that overrides some methods:

    @Override
public boolean isInTouchMode() {
    return false;
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
    return false;
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    return false;
}


Jason Shah explains everything in this post:

Handling Android 2.3 WebView's broken AddJavascriptInterface

(Apologies in advance to my normal readers for this technical topic.)

The Google Android team released the Android 2.3 ("Gingerbread") SDK two days ago, to much fanfare. This has sent the tech blogging world into a publishing frenzy, as it usually does. However, a potentially disastrous bug has surfaced that could crash literally thousands of apps in the Android Market immediately after opening the app.

The problem is described succintly here: http://code.google.com/p/android/issues/detail?id=12987 In short: Many apps show all or part of their UI with embedded WebViews that can render HTML. Those WebViews make use of a great feature that bridges JavaScript (in the HTML) to the native Java code that "surrounds" the WebView. This bridge is completely broken in Android 2.3. Trying to make even a basic call breaks the WebView immediately and crashes the app.

I believe members of the Android team are aware of the problem, and from early reports, it does not affect the Nexus S (the first Android 2.3 phone). This doesn't really help those of us working against the emulator, however.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜