Android 指定的子级已具有父级
我不知道发生了什么事。我的代码崩溃了,我找不到原因 我有一个LinearLayout,它是多个Web视图的容器Android 指定的子级已具有父级,android,android-webview,Android,Android Webview,我不知道发生了什么事。我的代码崩溃了,我找不到原因 我有一个LinearLayout,它是多个Web视图的容器 LinearLayout variableContent = (LinearLayout) this.findViewById(R.id.variableContent); for (int i=0; i<5;i++){ XMLModule modul = modulsRecuperats.get(i); myWebView webview = new myWeb
LinearLayout variableContent = (LinearLayout) this.findViewById(R.id.variableContent);
for (int i=0; i<5;i++){
XMLModule modul = modulsRecuperats.get(i);
myWebView webview = new myWebView(this);
WebView customWebViewContainer = (WebView) this.mInflater.inflate(R.layout.customwebview, null);
customWebViewContainer = webview._clientSettings(customWebViewContainer,progressDialog);
customWebViewContainer.loadData(modul.getContent(), "text/html", "UTF-8");
variableContent.addView(customWebViewContainer);
}
LinearLayout variableContent=(LinearLayout)this.findViewById(R.id.variableContent);
对于(inti=0;i你能发布“myWebView”类吗?尤其需要使用方法_clientSettings,以便我们知道那里发生了什么。问题是customWebViewContainer
已经有一个父级。视图
不能有两个父级,因此引发此异常。我只能假设调用webview。_clientSettings()
正在用另一个容器包装该视图。看起来您的variableContent已经有了一些内容。您可以执行variableContent.removeView()操作,然后调用for循环。但这没有意义,因为线性布局是一种可以包含多个子项的布局。。。