显示在子选项卡进度条,直到的WebView负荷 [英] Show a progress bar on a child tab until the WebView loads

查看:114
本文介绍了显示在子选项卡进度条,直到的WebView负荷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个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);
  }
}

这篇关于显示在子选项卡进度条,直到的WebView负荷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆