-1

我为 webview 设置了 SurfaceView,如下所示:

wv.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {  
        @Override
        public void onChildViewRemoved(View parent, View child) {}
        @Override
        public void onChildViewAdded(View parent, View child) {
            if(child.getClass().getName().equals("com.adobe.flashplayer.FlashPaintSurface")){
                Log.i("flash", "surface is open");
                ((SurfaceView)child).setZOrderOnTop(false); 
                ((SurfaceView)child).dispatchWindowFocusChanged(isHidden());
        }}
    });

但...

当我单击 WebViewText 时,尝试在那里写一些我的应用程序崩溃,并显示该错误日志:

03-07 10:14:37.425: E/AndroidRuntime(7378): FATAL EXCEPTION: main
03-07 10:14:37.425: E/AndroidRuntime(7378): java.lang.ClassCastException: android.webkit.WebTextView cannot be cast to android.view.SurfaceView

我是个白痴——忘了把括号放在 if(){} 中。请不要降低我的价格!

4

1 回答 1

2

您在if...之后缺少括号

wv.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {  
    @Override
    public void onChildViewRemoved(View parent, View child) {}
    @Override
    public void onChildViewAdded(View parent, View child) {
        if(child.getClass().getName().equals("com.adobe.flashplayer.FlashPaintSurface")) {
            Log.i("flash", "surface is open");
            ((SurfaceView)child).setZOrderOnTop(false); 
            ((SurfaceView)child).dispatchWindowFocusChanged(isHidden());
        }
    }
});
于 2013-03-07T08:29:11.043 回答