1

This is my code...

public class detailedview extends Activity
{
    WebView mWebView;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detailedview);
        GetSet gs = new GetSet();

        String title = gs.getTitle();
        String desc = gs.getDesc();

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);
        mWebView.getSettings().setTextSize(TextSize.SMALLER);
        mWebView.loadDataWithBaseURL("", "<p  align=\"justify\"><b> " + title+"</p></b><p align=\"justify\"><br>"+ desc + "</p></br>", "text/html", "utf-8", "");

I want to set a ProgressBar on the Activity. How can I achieve this? help me.

wattostudios
  • 8,446
  • 13
  • 40
  • 54
user1388681
  • 73
  • 3
  • 7
  • please refer this http://stackoverflow.com/questions/4331094/how-to-add-a-progress-bar-in-webview and override the function public void onProgressChanged(WebView view, int progress) of Webivew http://www.firstdroid.com/2010/08/04/adding-progress-bar-on-webview-android-tutorials/ – Dheeresh Singh May 30 '12 at 12:13

1 Answers1

1

The below code is used to show the progress bar:

ProgressDialog progressDialog = ProgressDialog.show(this, "Please Wait!", "Loading...");

and to disable it:

if (progressDialog != null) {
            progressDialog.dismiss();
    }

UPDATE:

this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.main);
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
                Window.PROGRESS_VISIBILITY_ON);
        final WebView webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("file:///android_asset/www/index.html");
        final Activity MyActivity = this;
        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {
                // Make the bar disappear after URL is loaded, and changes
                // string to Loading...
                MyActivity.setTitle("Loading...");
                MyActivity.setProgress(progress * 100); // Make the bar
                                                        // disappear after URL
                                                        // is loaded

                // Return the app name after finish loading
                if (progress == 100)
                    MyActivity.setTitle(R.string.app_name);
            }
        });
Shrikant
  • 6,769
  • 7
  • 38
  • 59
  • loadDataWithBaseURL how i will put this function what argument i ll put here when i will put webview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } – user1388681 May 30 '12 at 12:17
  • view.loadUrl(url); this i will have to apply in shouldOverrideUrlLoading() functaion right but in our code – user1388681 May 30 '12 at 12:25
  • in load() , this loadDataWithBaseURL() funcation is there which has argumnet when i appy this then they ask for 5 argument wat we have to fill in that argumnt???? – user1388681 May 30 '12 at 12:26