我在弹出框中加载了一个网页视图,并希望在弹出窗口顶部显示进度条,展示网页内容加载的进度。虽然我已经找到了一种显示加载进度条的方法,但是当这个网页视图在弹出框中加载时,进度条并不会在其上方显示。有人能否解释这是为什么呢?
以下是代码:
以下是代码:
@SuppressWarnings("static-access")
public void showPopUp(String url){
try{
Dialog dialog = new Dialog(Links.this);
LayoutInflater inflater = (LayoutInflater)getSystemService(Links.this.LAYOUT_INFLATER_SERVICE);
View vi = inflater.inflate(R.layout.link_popup, null);
dialog.setContentView(vi);
dialog.setTitle("Title here");
dialog.setCancelable(true);
WebView wb = (WebView) vi.findViewById(R.id.WebView01);
wb.setWebViewClient(new MyWebViewClient());
wb.getSettings().setJavaScriptEnabled(true);
wb.getSettings().setSupportZoom(true);
wb.loadUrl(url);
// final Activity MyActivity = this;
//
// progressDialog = ProgressDialog.show(dialog.getOwnerActivity(), "", "Loading....", true);
//
// wb.setWebChromeClient(new WebChromeClient() {
// public void onProgressChanged(WebView view, int progress)
// {
// MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// if(progress == 100){
// if(progressDialog.isShowing())
// progressDialog.dismiss();
// }
// }
// });
System.out.println("..loading url..");
dialog.show();
}catch(Exception e){
System.out.println("Exception while showing Agreement : " + e.getMessage());
}
}
这个功能没有生效,所以我做了注释。
注:[/code]标签保留。
link_popup.xml
[code]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="fill"
android:id="@+id/layout_root"
android:background="#000000"
>
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_alignParentTop="true"
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressbar_Horizontal"
android:max="100"
android:background="#228b22"
/>
<WebView
android:id="@+id/WebView01"
android:layout_below="@id/progressbar_Horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:scrollbars="@null"
/>
</RelativeLayout>
[/code]