Has anyone actually got this to work?  I have tried all the
combinations mentioned in this post, but none of them work for me.  My
code so far is posted below.  If you have a WebView working with a
progress bar, I would really appreciate it if you could post the
entire code to this thread.  Thanks

My class:

public class WebViewController extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().requestFeature(Window.FEATURE_PROGRESS);
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
Window.PROGRESS_VISIBILITY_ON);

        WebView webview = new WebView(this);
        setContentView(webview);
        setProgressBarVisibility(true);
        webview.getSettings().setJavaScriptEnabled(true);
        final Activity activity = this;
        webview.setWebChromeClient(new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
            activity.setProgress(progress * 100 );
          }
        });

        webview.setWebViewClient(new WebViewClient() {
          public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
            Toast.makeText(activity, "Oh no! " + description,
Toast.LENGTH_SHORT).show();
          }
        });

        webview.loadUrl("http://cnn.com/";);

    }
}

On Dec 18 2009, 10:43 pm, thehyperadvisor <thehyperadvi...@gmail.com>
wrote:
> I found that putting the line "getWindow().requestFeature
> (Window.FEATURE_PROGRESS);" higher in the code after "setContentView
> (R.layout.main);" worked for me.
>
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         // Let's display theprogressin the activity titlebar, like
> the
>         // browser app does.
>         getWindow().requestFeature(Window.FEATURE_PROGRESS);
>
>         setContentView(R.layout.main);
>
>        WebViewwebview= newWebView(this);
>         setContentView(webview);
>         setProgressBarVisibility(true);
>
>        webview.getSettings().setJavaScriptEnabled(true);
>
> On Dec 9, 8:02 am, Nugman <klaus.nuta...@googlemail.com> wrote:
>
> > Add this line of code:
>
> > ...
> > setContentView(webview);
> > setProgressBarVisibility(true);
> > ...
>
> > Greets Klaus
>
> > On 7 Dez., 16:33, Marton Kodok <pentiu...@gmail.com> wrote:
>
> > > I am still after a solution to this problem too.
>
> > > 2009/12/5 Richard <ldonel...@gmail.com>
>
> > > > I'm following the Android docs example for awebviewprogresstoo.
>
> > > > My code compiles and runs, but I don't actually see theprogressbar.
> > > > I confirmed that the onProgress method was firing (via debug).  Can
> > > > someone point me down the right path?
>
> > > > public class WebViewTest extends Activity {
> > > >    /** Called when the activity is first created. */
> > > >   �...@override
> > > >    public void onCreate(Bundle savedInstanceState) {
> > > >        super.onCreate(savedInstanceState);
>
> > > >        // Let's display theprogressin the activity titlebar, like
> > > > the
> > > >        // browser app does.
> > > >         getWindow().requestFeature(Window.FEATURE_PROGRESS);
>
> > > >        WebViewwebview= newWebView(this);
> > > >        webview.getSettings().setJavaScriptEnabled(true);
>
> > > >        final Activity activity = this;
> > > >        webview.setWebChromeClient(new WebChromeClient() {
> > > >          public void onProgressChanged(WebViewview, intprogress) {
> > > >            // Activities and WebViews measureprogresswith different
> > > > scales.
> > > >            // Theprogressmeter will automatically disappear when we
> > > > reach 100%
> > > >            activity.setProgress(progress* 1000);
> > > >          }
> > > >        });
>
> > > >        webview.setWebViewClient(new WebViewClient() {
> > > >           public void onReceivedError(WebViewview, int errorCode,
> > > > String description, String failingUrl) {
> > > >            Toast.makeText(activity, "Oh no! " + description,
> > > > Toast.LENGTH_SHORT).show();
> > > >          }
> > > >        });
>
> > > >        webview.loadUrl("http://yahoo.com/";);
>
> > > >        setContentView(webview);
> > > >     }
> > > > }
>
> > > > On Nov 1, 7:18 am, Marton Kodok <pentiu...@gmail.com> wrote:
> > > > > Thank you!
>
> > > > > 2009/11/1 donthorp <dth...@gmail.com>
>
> > > > > > You need to make sure you're requesting the feature before you set
> > > > > > your content view.
>
> > > > > > On Oct 30, 1:01 pm, Marton Kodok <pentiu...@gmail.com> wrote:
> > > > > > > I have this code to setup aprogressbarfor mywebview.
> > > > > > > I get an error on runtime on the first marked line. What is wrong?
>
> > > > > > > getWindow().requestFeature(Window.FEATURE_PROGRESS); // hangs out 
> > > > > > > on
> > > > this
> > > > > > > line
>
> > > > > > >         final Activity activity = this;
> > > > > > >        webview.setWebChromeClient(new WebChromeClient() {
> > > > > > >           public void onProgressChanged(WebViewview, intprogress) 
> > > > > > > {
> > > > > > >             // Activities and WebViews measureprogresswith
> > > > different
> > > > > > > scales.
> > > > > > >             // Theprogressmeter will automatically disappear when
> > > > we
> > > > > > reach
> > > > > > > 100%
> > > > > > >             activity.setProgress(progress* 1000);
> > > > > > >           }
> > > > > > >         });
>
> > > > > > > 1. What I am doing wrong?
> > > > > > > 2. the Debugger doesn't pick up the line, it was a pain to detect 
> > > > > > > the
> > > > > > line,
> > > > > > > what is missing from Eclipse? I get source path not found error.
>
> > > > > > > Marton
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Beginners" group.
> > > > > > To post to this group, send email to
> > > > android-beginners@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > android-beginners+unsubscr...@googlegroups.com<android-beginners%2Bunsubscr
> > > > > >  i...@googlegroups.com>
> > > > <android-beginners%2bunsubscr...@googlegroups.com<android-beginners%252Buns
> > > >  ubscr...@googlegroups.com>
>
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/android-beginners?hl=en
>
> > > > > --
> > > > > Márton
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Beginners" group.
> > > > To post to this group, send email to android-beginners@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-beginners+unsubscr...@googlegroups.com<android-beginners%2Bunsubscr
> > > >  i...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-beginners?hl=en
>
> > > --
> > > Márton
>
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to