Tôi có hộp thoại bật lên trong đó tôi đang tải chế độ xem web. Tôi muốn hiển thị progressBar trong khi webview đang tải trên đầu cửa sổ bật lên. Tôi đã tìm thấy cách hiển thị thanh tiến trình tải trong khi trang web tải nhưng nếu webview này đang tải trong hộp thoại bật lên thì progressBar không được hiển thị trên đầu trang của nó. Ai đó có thể giải thích lý do tại sao điều này xảy ra.Hiển thị tiến trình trong cửa sổ bật lên
Đây là mã
[code]
@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]
Nó không làm việc vì vậy tôi nhận xét nó.
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]
Mã ở đâu? – davidcesarino