【发布时间】:2014-08-25 06:56:34
【问题描述】:
我正在开发一个应用程序,它有一个片段可以在 webview 上显示网站。对于慢速连接,加载网站需要一些时间,并且应用程序会在几秒钟内变为空白,所以我想在我的片段中显示一个全屏加载微调器。我找到了源代码,但我不知道如何在我的扩展片段的类中实现它。
这是我想要在显示网站之前显示全屏加载的片段。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.fragment_a, container, false);
String url="http://www.hotelsearcher.net/";
Bundle args = getArguments();
if (args != null){
url = args.getString("position");
}
WebView webView= (WebView) V.findViewById(R.id.webView1);
WebSettings webViewSettings = webView.getSettings();
webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webViewSettings.setJavaScriptEnabled(true);
webViewSettings.setPluginState(PluginState.ON);
webView.setWebViewClient(new WebViewClient());
adview =(AdView) V.findViewById(R.id.ads);
Ads.loadAds(adview);
webView.loadUrl(url);
return V;
}
}
我发现这是代码:https://gist.github.com/daichan4649/5344979/download#
谁能告诉我应该写什么。实现该功能。
【问题讨论】:
标签: android android-fragments webview