【发布时间】:2012-11-18 07:08:27
【问题描述】:
我正在使用“android.support.v4.view.ViewPager”开发一个项目。有 2 个选项卡,在每个选项卡中我想显示不同的 WebView。这是其中一个选项卡的代码及其布局:
TabOne.java
public class TabOne extends Fragment
{
WebView myWebView;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.tabone, container, false);
WebView myWebView = (WebView) view.findViewById(R.id.webview);
myWebView.loadUrl("file:///android_asset/help/index.html");
return view;
}
}
tabone.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
问题是在第一个选项卡中,WebView 正确加载。在另一个与声明完全相同的选项卡上,我无法聚焦元素,有时我会得到一些强制关闭。如果我在第二个有错误的选项卡上,并且我将方向切换为横向,则第二个选项卡已完美加载,但是当我切换到第一个选项卡时,我得到了错误。这是 LogCat 错误:
11-18 09:00:37.460: E/webcoreglue(29444): Should not happen: no rect-based-test nodes found
【问题讨论】:
-
onActivityCreated的覆盖没用,你直接调用super..
-
我不觉得,你贴的日志跟crash有关,把日志贴在Fatal exception下面
-
pastebin.com/A2Evqxyk :这是完整的日志。谢谢!
标签: android tabs webview swipe