我将SurfaceView设置为webview,就像那样:
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(){}。请不要降低我的费率!
答案 0 :(得分: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());
}
}
});