我已經把WebView
在我的片段佈局:的WebView在片段不加載
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.deped.k12.GradeSheet"
android:background="#fafafa">
<!-- TODO: Update blank fragment layout -->
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView" />
</FrameLayout>
但是,當我嘗試從它加載任何網站。我只是得到一個空白WebView
:
我試圖尋找Android監視器中的錯誤消息,但沒有。
這是我在片段使用代碼加載網址:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_grade_sheet, container, false);
String url = "http://www.google.com/";
WebView wv = (WebView)view.findViewById(R.id.webView);
WebSettings settings = wv.getSettings();
wv.setWebChromeClient(new WebChromeClient() {
});
final String mimeType = "text/html";
final String encoding = "UTF-8";
String html = "";
settings.setJavaScriptEnabled(true);
wv.loadDataWithBaseURL(url, html, mimeType, encoding, "");
return view;
}
我還添加了正確的權限:
什麼可能是這裏的問題?