I am working on a project with "android.support.v4.view.ViewPager". There are two tabs in each tab, and I want to show a different WebView. Here is the code for one of these tabs and layout:
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>
The problem is that on the first tab, WebView loads differently. On another tab, which is declared the same way, I cannot focus the elements, and sometimes I get some locks. If I am on the second tab that has an error and I switch the orientation to Landscape, the second tab loads fine, but when I switch to the first tab, I get an error. Here is the LogCat error:
11-18 09:00:37.460: E/webcoreglue(29444): Should not happen: no rect-based-test nodes found
source share