當我嘗試使用webview加載網站時,頁面會加載。但是,該頁面不會加載所有內容。我得到了PHP部分和Youtubevídeo,但它沒有出現。這是我的代碼:Webview不會加載整個網站
public class ChatFragment extends Fragment {
public ChatFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_chat, container, false);
String url = "mywebpath/index.php"; // It has the http part
WebView webView = (WebView) view.findViewById(R.id.chat);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
if (Build.VERSION.SDK_INT >= 19) {
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
else {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
WebSettings webSettings = webView.getSettings();
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
return view;
}
這是網站:http://i.imgur.com/Tk8UIvL.jpg
這是web視圖結果:http://i.imgur.com/reDPlx1.png
感謝這麼多的關注
附:聊天開始於php部分,然後出現一個div。
它的工作。非常感謝你的幫助! – NyanMe