<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Droid Hacks &#187; webview</title>
	<atom:link href="http://droidhacks.com/tag/webview/feed/" rel="self" type="application/rss+xml" />
	<link>http://droidhacks.com</link>
	<description>Tips and Tricks for Android Users</description>
	<lastBuildDate>Fri, 27 Aug 2010 18:44:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting WebView To Load New Pages</title>
		<link>http://droidhacks.com/2009/06/getting-webview-to-load-new-pages/</link>
		<comments>http://droidhacks.com/2009/06/getting-webview-to-load-new-pages/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 19:31:16 +0000</pubDate>
		<dc:creator>Lead Hacker</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[webview]]></category>

		<guid isPermaLink="false">http://droidhacks.com/?p=47</guid>
		<description><![CDATA[There are a bunch of examples of using WebView to display HTML content loaded from the web in an Android app, including the sample from Google for the WebView class. However the ones I found generally don&#8217;t load new pages on their own. I can load up Google, but if you click on anything in]]></description>
			<content:encoded><![CDATA[<p>There are a bunch of examples of using <a href="http://developer.android.com/reference/android/webkit/WebView.html">WebView</a> to display HTML content loaded from the web in an Android app, including the <a href="http://developer.android.com/guide/tutorials/views/hello-webview.html">sample from Google for the WebView class</a>. However the ones I found generally don&#8217;t load new pages on their own. I can load up Google, but if you click on anything in the app it launches a browser and takes the user out of the app. The answer to the problem is in the additional points on that Hello, WebView page &#8211; you need to set a new WebViewClient to handle the URL load requests. Their example is very helpful, but I prefer to do the override with an anonymous inner class:</p>
<pre>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webview = new WebView(this);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(new WebViewClient() {
        @Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
    	    return true;
    	}
    });
    webview.loadUrl("http://google.com");
    setContentView(webview);
}</pre>
<p>However, if you follow a link to an image it downloads instead of opens in the view. That&#8217;s the same thing the built in browser does, but wasn&#8217;t the behavior I expected. I&#8217;ll have to figure out how to handle that a bit better.</p>
]]></content:encoded>
			<wfw:commentRss>http://droidhacks.com/2009/06/getting-webview-to-load-new-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
