如何在webview中的链接上每次点击时加载/显示ProgressBar? 目前点击后,页面空白将近5到7秒,然后出现ProgessBar ......
答案 0 :(得分:0)
可能您可以使用WebViewClient(请参阅onPageStarted(WebView view, String url, Bitmap favicon)
)并覆盖其方法
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
}
开始展示您的ProgressBar ...
例如:
df['block_encounter_no'] = (df.Class != df.Class.shift()).mask(df.Class.isnull())
.groupby(df.Class).cumsum()
print (df)
a b Class block_encounter_no
0 10 0 NaN NaN
1 11 1 NaN NaN
2 12 2 NaN NaN
3 13 3 NaN NaN
4 14 4 a 1.0
5 15 5 a 1.0
6 16 6 a 1.0
7 17 7 a 1.0
8 18 8 NaN NaN
9 19 9 NaN NaN
10 20 10 a 2.0
11 21 11 a 2.0
12 22 12 a 2.0
13 23 13 a 2.0
14 24 14 a 2.0
15 25 15 NaN NaN
16 26 16 NaN NaN
17 27 17 b 1.0
18 28 18 b 1.0
19 29 19 b 1.0
答案 1 :(得分:0)
执行此操作的最佳做法是使用WebViewClient。
WebView webView;
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview_layout);
webView = (WebView) findViewById(R.id.webView_blog);
progressBar = (ProgressBar) findViewById(R.id.loading);
lala_icon = (ImageView) findViewById(R.id.lala_icon);
webView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
progressBar.setVisibility(View.VISIBLE);
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.e("url", url);
progressBar.setVisibility(View.VISIBLE);
view.loadUrl(url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
Log.e("Loading URL", url);
progressBar.setVisibility(View.VISIBLE);
}
public void onPageFinished(WebView view, String url) {
try {
if (progressBar.getVisibility() == View.VISIBLE) {
progressBar.setVisibility(View.GONE);
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
});
}
快乐编码。