正如我们在片段中加载Webview一样:
private WebView viewer = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
viewer = (WebView) inflater
.inflate(R.layout.tut_view, container, false);
return viewer;
}
public void updateUrl(String newUrl) {
if (viewer != null) {
viewer.loadUrl(newUrl);
}
}
但我想使用线性布局而不是webview。 我试试这个,但错误就出来了。
private LinearLayout viewer ;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
viewer = (LinearLayout) inflater.inflate(R.layout.tut_view, container, false);
View fragment = inflater.inflate(R.layout.tut_view, null);
return viewer;
}
public void updateUrl(String newUrl) {
if (viewer != null) {
}
}