WebView.destroy() called while WebView is still attached to window.
解决方法:
现在总结下这个问题的解决办法。先大概解释下这个错误,这个错误从字面意思来说是当你结束webview的时候,Webview还依附在父控件下,使用解决这个问题
就是在WebView.destroy()前要解除他们之间的依附关系。一般会碰上这个问题应该是这样对webview进行了操作:
protected void onDestroy()
{
if (adView != null)
{
adView.destroy();
}
}
附上一段详细的正确代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webviewRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/headerAlarmsWebViewTxt"
android:layout_marginBottom="0dip"
android:hapticFeedbackEnabled="true"
android:overScrollMode="never"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbars="none" />
</RelativeLayout>
Then you assign it to an instance variable e.g. :
_layout = (RelativeLayout) findViewById(R.id.webviewRelativeLayout);
webView = (WebView) findViewById(R.id.webView1);
and on Destroy do something like this:
@Override
protected void onDestroy() {
super.onDestroy();
_layout.removeView(webView);
webView.removeAllViews();
webView.destroy();
}
一般看了这段代码就能明白问题所在了。
转载地址:
(136条消息) Error: WebView.destroy() called while still attached 的解决办法_极客公园的博客-CSDN博客