显示在子选项卡进度条,直到的WebView负荷选项卡、负荷、进度条、WebView

由网友(风筝、在阴天搁浅。)分享简介:在一个Android应用程序我使用的是和TabView的其中一个选项卡显示的WebView。但页面是空白的,直到网页加载。如何将一个显示一个进度条,直到页面加载?它不能在标题栏中,因为这是隐藏的选项卡的主机。In an Android app I am using a TabView and one of the t...

在一个Android应用程序我使用的是和TabView的其中一个选项卡显示的WebView。但页面是空白的,直到网页加载。如何将一个显示一个进度条,直到页面加载?它不能在标题栏中,因为这是隐藏的选项卡的主机。

In an Android app I am using a TabView and one of the tabs shows a WebView. But the page is blank until the web page loads. How would one show a progress bar until the page loads? It cannot be in the title bar because that is hidden by the tab host.

推荐答案

我用一个进度这一点。有了这样的布局:

I use a ProgressBar for this. With a layout like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout [...]>
  <WebView android:id="@+id/WebView"
    android:layout_width="fill_parent" android:layout_height="fill_parent"/>
  <ProgressBar android:id="@+id/ProgressBar" android:layout_centerInParent="true"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    style="?android:attr/progressBarStyleLarge"
    android:visibility="gone"/>
</RelativeLayout>

我隐藏和使用显示进度指示器:

I hide and show the progress indicator using:

WebView webView = (WebView) findViewById(R.id.WebView);
final ProgressBar progess = (ProgressBar) findViewById(R.id.ProgressBar);
webView.setWebViewClient(new WebViewClient() {
  public void onPageStarted(WebView view, String url, Bitmap favicon) {
    progess.setVisibility(View.VISIBLE);
  }
  public void onPageFinished(WebView view, String url) {
    progess.setVisibility(View.GONE);
  }
}
阅读全文

相关推荐

最新文章