Rendering Web Pages Inside Android Activities
0
While you create Android activities, you supply the activity view content
either through XML or dynamically through the code. But, sometimes the content
in the view, specifically the static content (content that does not change with
different runs) may be a web page; e.g. "Help" Activity or "Terms and
Conditions" Activity of your application.
These contents can be done as web pages, and that will help you in changing
the content without affecting the client side application binary. However,
sometimes you need to open these pages inside your application as an activity, and
not through the web-browser, e.g. open "Terms and Conditions" web page for the
user to accept or reject through button actions.
Android has a great widget supplying this capability – the WebView
component. It accepts either plain text as you would use in the TextView
component or a URL to a web page to render inside your activity.
The following example shows a layout of a sample activity containing WebView
to show the eSpace site homepage:
You
first create the layout XML file that contains your component as follows:
And then supply the URL to WebView through your activity "onCreate" method:
Now, the given URL is rendered inside the WebView widget and you can deal
with the opened web page with all functionality available from the Android
web-kit (scroll, zoom in, zoom out, etc).
Post a Comment
eSpace podcast Prodcast
Archive
- September 2011
- April 2011
- March 2011
- December 2010
- November 2010
- September 2010
- August 2010
- July 2010
- June 2010
- April 2010
- March 2010
- November 2009
- October 2009
- September 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- September 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- January 2008
- April 2007
- March 2007
Latest Comments
- SpectraMind Commented on Egypt Wins UK's National Outsourcing Association Award
- Rofaida Awad Commented on Go Egypt Go!
- Different Mike Commented on Only idiots change their iPhone root password!
- Mike Commented on Only idiots change their iPhone root password!
- smile Commented on Only idiots change their iPhone root password!

