HelloWebView - WebViewClient odd behaviour

by Christer 脴stergaard » Fri, 04 Sep 2009 01:52:54 GMT


Sponsored Links
 Hi everybody,

Have been going through the HelloWebView tutorial. First I did all the
coding my self. Went perfectly fine. Loaded the Google address. Then I
added the code for HelloWebViewClient. As soon as I added the
webview.setWebViewClient(new HelloWebViewClient()); I end up getting
nothing but black in the content area.

After working a bit with it, I reversed everything, and copied the
code from the tutorial. Same behaviour. If I take the aforementioned
line of code out, then it works again.

Does anyone have a clue to why this is happening?

Kind regards,
Christer

public class HelloWebView extends Activity {
    /** Called when the activity is first created. */
    private WebView webview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new HelloWebViewClient());
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl(" http://www.google.com ");

    }

    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String
url) {
            view.loadUrl(url);
            return true;
        }
    }


}

--~--~---------~--~----~------------~-------~--~----~



HelloWebView - WebViewClient odd behaviour

by tinyang » Fri, 04 Sep 2009 03:12:22 GMT


 Hello Christer.

Have you tried that line without the Hello?

webview.setWebViewClient(new WebViewClient());



-----Original Message-----
From: android-beginners@googlegroups.com
[mailto:android-beginn...@googlegroups.com] On Behalf Of Christer stergaard
Sent: Thursday, September 03, 2009 11:06 AM
To: Android Beginners
Subject: [android-beginners] HelloWebView - WebViewClient odd behaviour


Hi everybody,

Have been going through the HelloWebView tutorial. First I did all the
coding my self. Went perfectly fine. Loaded the Google address. Then I added
the code for HelloWebViewClient. As soon as I added the
webview.setWebViewClient(new HelloWebViewClient()); I end up getting nothing
but black in the content area.

After working a bit with it, I reversed everything, and copied the code from
the tutorial. Same behaviour. If I take the aforementioned line of code out,
then it works again.

Does anyone have a clue to why this is happening?

Kind regards,
Christer

public class HelloWebView extends Activity {
    /** Called when the activity is first created. */
    private WebView webview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        webview = (WebView) findViewById(R.id.webview);
        webview.setWebViewClient(new HelloWebViewClient());
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl(" http://www.google.com ");

    }

    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String
url) {
            view.loadUrl(url);
            return true;
        }
    }


}


No virus found in this incoming message.
Checked by AVG -  http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.13.71/2332 - Release Date: 9/2/2009
6:03 PM


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


HelloWebView - WebViewClient odd behaviour

by Christer 脴stergaard » Fri, 04 Sep 2009 15:10:50 GMT


 Hi,

Thank you for your reply.

Your suggestion actually takes away the point of the HelloWebView
tutorial, in which we are shown how to intercept the actions and have
more control over the view by creating a sub-class of WebViewClient.

Anyways, of course, any input is appreciated, and actually, I do get
the same behavior when using WebViewClient!!! This strikes me as very
odd, because what we're basically doing is replacing default behaviour
with default behavirour, no?

Any suggestions?

Thanks in advance,
Christer



--~--~---------~--~----~------------~-------~--~----~



HelloWebView - WebViewClient odd behaviour

by tinyang » Sat, 05 Sep 2009 00:04:59 GMT


 Oops.  :)

I did not look at your lesson.  I did however use webview for one of my
first activities I built in Android after sucessfully completing the
helloandroid lesson, and it worked a charm for me.  Here is the code which
works fine for me.  HTH, Happy coding.

Public class webtest extends Activity (
        WebView webview; //declare webview variable
        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
          webview = (WebView) findViewById(R.id.webview); //link java code
to xml gui
        webview.setWebViewClient(new WebViewClient()); //instantiate new
webviewclient
        webview.getSettings().setJavaScriptEnabled(true); //enable
javascript for this new webviewclient
        webview.loadUrl(" http://www.google.com/" ;); //load web address
        }
} 

-----Original Message-----
From: android-beginners@googlegroups.com
[mailto:android-beginn...@googlegroups.com] On Behalf Of Christer stergaard
Sent: Friday, September 04, 2009 2:10 AM
To: Android Beginners
Subject: [android-beginners] Re: HelloWebView - WebViewClient odd behaviour


Hi,

Thank you for your reply.

Your suggestion actually takes away the point of the HelloWebView tutorial,
in which we are shown how to intercept the actions and have more control
over the view by creating a sub-class of WebViewClient.

Anyways, of course, any input is appreciated, and actually, I do get the
same behavior when using WebViewClient!!! This strikes me as very odd,
because what we're basically doing is replacing default behaviour with
default behavirour, no?

Any suggestions?

Thanks in advance,
Christer




No virus found in this incoming message.
Checked by AVG -  http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.13.71/2332 - Release Date: 9/3/2009
6:05 PM


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. (Closed)WTB : Motorola Milestone 2nd

Misi om & rekan2,
Karna udah dapat tawarin menarik dr Mr. Nice GumXX jg dr milis jd thread ini sy 
tutup.

Thx rekan2 atas tawaran2nya.
Rgds,

-droidless-

-- 
===============
"

2. [WTShare] UPnPlay + PS3 Media Server + RockPlayer == AWESOME!!

Akhirnya berhasil play file avi yg disimpen di PC lewat N1 gw..

Caranya, install PS3 Media Server di PC (http://ps3mediaserver.blogspot.com/),
set konfigurasi seperlunya.. terus install UPnPlay dari market.. install
juga RockPlayer (Universal), terserah dari pasarpagi apa malem..

Waktu milih file di UPnPlay, pilih #--TRANSCODE--# di folder yg berisi file
yg diinginkan, pilih file-nya, terus pilh [No encoding], abis itu play pake
RockPlayer.. :D

Maap klo tutorialnya singkat en kurang jelas.. dcoba2 sndiri aj, gw rada
ribet ngejelasinnya, baru sukses soalnya daritadi nyari Media Server yg
bener2 bagus susah banget.. paling pas pake PS3 Media Server ini.. :D

-- 
===============
"

3. How to declare device as "hdpi" ev en when it's not鈥?脿 la Galaxy Tab

4. android manifest.xml missing

5. Setting Custom ringtone to contacts

6. New error in the Market

7. Auto android:debuggable. Anybody got it working?