我目前正在尝试在当前加载 Web 视图时显示滚轮进度条。我的代码有一些问题。关于我的代码有什么问题或缺失的任何想法?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_main);
这是我在 Web 视图部分的代码。
setProgressBarIndeterminateVisibility(true);
wv1 = (WebView)findViewById(R.id.wv1);
wv1.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
wv1.getSettings().setSupportZoom(false);
wv1.getSettings().setSupportMultipleWindows(false);
wv1.setHorizontalScrollBarEnabled(false);
wv1.setVerticalScrollBarEnabled(false);
wv1.getSettings().setUseWideViewPort(true);
wv1.getSettings().setLoadWithOverviewMode(true);
final Activity activity = this;
wv1.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView viewx, String urlx) {
viewx.loadUrl(urlx);
return false;
}
public void onProgressChanged (WebView view, int progress){
activity.setTitle("Loading..");
activity.setProgress(progress * 100);
if (progress == 100)
setProgressBarIndeterminateVisibility(false);
activity.setTitle("My Title");
}
}
);
wv1.loadUrl(nFeed);