android物流进度条,AndroidProgressLayout

下面介绍和webview使用的情况:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:progressLayout="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:id="@+id/progress_layout"

progressLayout:progressBackground="#33B5E5"

progressLayout:progress="false"

>

android:id="@+id/web_view"

android:layout_width="match_parent"

android:layout_height="match_parent" />

根据webview的加载状态显示或者隐藏progressbar:webView.setWebViewClient(new WebViewClient() {

@Override

public void onPageStarted(WebView view, String url, Bitmap favicon) {

progressLayout.setProgress(true);

}

@Override

public void onPageFinished(WebView view, String url) {

progressLayout.setProgress(false);

}

@Override

public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

Log.d(TAG, "onReceivedError: " + errorCode + " : " + description + " : " + failingUrl);

super.onReceivedError(view, errorCode, description, failingUrl);

}

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可根据加载情况显示提示信息的载入视图,如,加载失败后提示"加载失败"、"网络连接失败"等等。用一个控件就可以管理整个的加载过程。确实方便了。项目地址:https://github.com/antonkrasov/AndroidProgressLayout 效果图:如何使用将<com.github.androidprogresslayout.ProgressLayout> 作为整个布局的根:<com.github.androidprogresslayout.ProgressLayout         xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:app="http://schemas.android.com/apk/res-auto"         android:id="@ id/progress_layout"         android:layout_width="match_parent"         android:layout_height="match_parent"               >     ...你的页面 </com.github.androidprogresslayout.ProgressLayout>2. 得到ProgressLayoutProgressLayout progressLayout = (ProgressLayout) this.findViewById(R.id.progress_layout);3. 通过progressLayout.showContent()来打开loading,或者你也可以使用属性:app:progress="true"mHandler.postDelayed(new Runnable() {     @Override     public void run() { //progressLayout.showContent();//加载成功,关闭loading progressLayout.showErrorText("加载失败");//加载失败,并显示提示信息     } }, 2000);利用Handler模拟了一个2秒的载入过程。如果载入成功,调用progressLayout.showContent()关闭loading。如果载入失败,调用progressLayout.showErrorText("加载失败")显示失败信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值