<?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"
	>

<channel>
	<title>Warrior Point</title>
	<atom:link href="http://www.warriorpoint.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.warriorpoint.com/blog</link>
	<description>Latest News and Tutorials on Salesforce.com, SaaS, and on-demand software</description>
	<pubDate>Fri, 02 Jul 2010 15:45:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Samsung may drop Windows Mobile and switch to Android</title>
		<link>http://www.warriorpoint.com/blog/2009/11/10/samsung-may-drop-windows-mobile-and-switch-to-android/</link>
		<comments>http://www.warriorpoint.com/blog/2009/11/10/samsung-may-drop-windows-mobile-and-switch-to-android/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 03:36:52 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=388</guid>
		<description><![CDATA[I just found this article from reddit&#8230;
Samsung may drop Windows Mobile for Android
Apparently Samsung is going to stop using Windows Mobile on its cellphones and will concentrate on Android!! I have been a supporter of Android since its inception and stories like these bring tears of joy to my eyes.
Oh, and there&#8217;s something about Samsung [...]]]></description>
			<content:encoded><![CDATA[<p>I just found this article from reddit&#8230;<br />
<a href="http://www.wiseandroid.com/NewsItem.aspx?category=News&amp;path=November&amp;itemid=16" target="_blank">Samsung may drop Windows Mobile for Android</a></p>
<p>Apparently Samsung is going to stop using Windows Mobile on its cellphones and will concentrate on Android!! I have been a supporter of Android since its inception and stories like these bring tears of joy to my eyes.</p>
<p>Oh, and there&#8217;s something about Samsung rolling out their own open source OS called &#8220;Bada&#8221;. Good for them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/11/10/samsung-may-drop-windows-mobile-and-switch-to-android/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: Simplified source code for parsing and working with XML data and web services in Android</title>
		<link>http://www.warriorpoint.com/blog/2009/07/19/android-simplified-source-code-for-parsing-and-working-with-xml-data-and-web-services-in-android/</link>
		<comments>http://www.warriorpoint.com/blog/2009/07/19/android-simplified-source-code-for-parsing-and-working-with-xml-data-and-web-services-in-android/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 02:05:24 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=378</guid>
		<description><![CDATA[In my previous post I linked to a terrific website (Working with XML on Android) which describes how you can read and parse XML documents in Android. The code supplied by that website used polymorphism to show 4 different methods for parsing the XML data. I vowed to simplify that and share the new source [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/" target="_blank">previous post</a> I linked to a terrific website (<a title="http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&amp;S_TACT=105AGX59&amp;S_CMP=grlnxw82" href="http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&amp;S_TACT=105AGX59&amp;S_CMP=grlnxw82" target="_blank">Working with XML on Android</a>) which describes how you can read and parse XML documents in Android. The code supplied by that website used polymorphism to show 4 different methods for parsing the XML data. I vowed to simplify that and share the new source code.</p>
<p>To <a href="http://www.warriorpoint.com/blog/downloads/" target="_blank">download the AndroidXmlSimple project click here</a>. You will be taken to another page where you can click to download to the ZIP file.</p>
<p>Below are some instructions on setting yourself up with this source code and customizing it for your own XML data.</p>
<p> <span id="more-378"></span>
<p>1. Download the file AndroidXmlSimple.zip</p>
<p>2. Unzip it on your disk.</p>
<p>3. Open Eclipse and import the Android project into your workspace.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/01import1.jpg"><img title="01 Import" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="456" alt="01 Import" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/01import-thumb1.jpg" width="388" border="0" /></a> </p>
<p>4. The project will look like this:</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/02project1.jpg"><img title="02 project" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="440" alt="02 project" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/02project-thumb1.jpg" width="391" border="0" /></a> </p>
<p>5. This new project opens up an XML document (the same RSS feed as the original example) and displays it using a ListActivity.</p>
<p>6. The classes are:</p>
<p>- MessageList.java: the main Activity</p>
<p>- Message.java: object that stores the parsed XML data</p>
<p>- RssHandler.java: object that parses the XML data</p>
<p>- BaseFeedParser.java: object that initiates the starting point and configurations for the XML data that should be parsed. </p>
<p>7. To customize this project for your own feed, edit the file BaseFeedParser.java.</p>
<p>Update the URL location here:</p>
<pre class="csharpcode" style="width: 69.26%; height: 45px"><span class="kwrd">static</span> String feedUrlString = <span class="str">&quot;http://www.androidster.com/android_news.rss&quot;</span>;</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Update the hierarchy of nodes here:</p>
<pre class="csharpcode" style="width: 64.36%; height: 75px"><span class="kwrd">static</span> final String RSS = <span class="str">&quot;rss&quot;</span>;
<span class="kwrd">static</span> final String CHANNEL = <span class="str">&quot;channel&quot;</span>;
<span class="kwrd">static</span> final String ITEM = <span class="str">&quot;item&quot;</span>;</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Update the node names that repeat here:</p>
<pre class="csharpcode" style="width: 65.33%; height: 98px"><span class="kwrd">static</span> final String PUB_DATE = <span class="str">&quot;pubDate&quot;</span>;
<span class="kwrd">static</span> final String DESCRIPTION = <span class="str">&quot;description&quot;</span>;
<span class="kwrd">static</span> final String LINK = <span class="str">&quot;link&quot;</span>;
<span class="kwrd">static</span> final String TITLE = <span class="str">&quot;title&quot;</span>;</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>And as in the previous post, if you change any names of the constants, you will need to update other sections of the code-base, for example below in BaseFeedParser.java, and in a few places in RssHandler.java.</p>
<pre class="csharpcode" style="width: 68.29%; height: 372px">        item.getChild(TITLE).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setTitle(body);
            }
        });
        item.getChild(LINK).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setLink(body);
            }
        });
        item.getChild(DESCRIPTION).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setDescription(body);
            }
        });
        item.getChild(PUB_DATE).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setDate(body);
            }
        });</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>Please leave a comment if you download this ZIP file – I’d like to know if you found this useful. And let me know if it does what you expected after reading my post. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/07/19/android-simplified-source-code-for-parsing-and-working-with-xml-data-and-web-services-in-android/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: Reading, using and working with XML data and web services in Android</title>
		<link>http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/</link>
		<comments>http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 00:37:33 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=363</guid>
		<description><![CDATA[One of the most powerful aspects of any mobile application for a 3G phone is that it can connect to the Internet. By connecting to the Internet the application can offer much more value to the user since it becomes an interface for a web-based component, e.g. using Twitter’s API to create a Twitter application [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most powerful aspects of any mobile application for a 3G phone is that it can connect to the Internet. By connecting to the Internet the application can offer much more value to the user since it becomes an interface for a web-based component, e.g. using Twitter’s API to create a Twitter application so that you can get your Twitter updates without having to open the mobile browser. The most common way of interfacing with a web-based component is by using web services in XML format.</p>
<p>While trying to developer my own app which reads a web service from my own server, I ran into a lot of difficulties in implementing the client that consumes the web service. Android does not have libraries for XPath handling of XML documents, so it makes deciphering XML data a little bit more difficult. From what I’ve read online the Android team is currently working on including such libraries in future versions.</p>
<p>After some digging around I found an amazing link that shows different methods for consuming an XML file in Android and parsing through it without the use of XPaths. The link is this: <a title="http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&amp;S_TACT=105AGX59&amp;S_CMP=grlnxw82" href="http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&amp;S_TACT=105AGX59&amp;S_CMP=grlnxw82" target="_blank">Working with XML on Android</a>. To start off, this link is an absolute must-read. Everything that I am going to write in my post here relates to this link. The code offered on that webpage uses polymorphism to show you 4 different methods of working with XML data. It provides a fully-functional Android application and all the source code for it. The source code can be found here: <a title="http://www.ibm.com/developerworks/apps/download/index.jsp?contentid=398121&amp;filename=AndroidXml.zip&amp;method=http&amp;locale=worldwide" href="http://www.ibm.com/developerworks/apps/download/index.jsp?contentid=398121&amp;filename=AndroidXml.zip&amp;method=http&amp;locale=worldwide">AndroidXML.zip</a>.</p>
<p>My post today will concentrate on how to customize the code from the application in the above link, in order to read and parse your own XML data. If you are a Java pro, you might not need this post. My Java is a little rusty, so I needed some time to figure out exactly what I had to change and where in order to get this to work with my own web service XML. Now that I’ve figured it out, I thought I’d share it. In my next post I will give the simplified version of this code – where there is no polymorphism, and thus there are only the minimum number of classes needed to implement this XML-reading solution. I can’t offer this simplified code right now – because I haven’t coded it yet :).</p>
<p>So until I post the simplified source code for working with XML data in Android, here are some tips on getting through the larger polymorphism-based source code and customizing it for your own XML data:</p>
<p><span id="more-363"></span></p>
<p>1. First off, read over the link <a title="http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&amp;S_TACT=105AGX59&amp;S_CMP=grlnxw82" href="http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&amp;S_TACT=105AGX59&amp;S_CMP=grlnxw82" target="_blank">Working with XML on Android</a> as much as you can.</p>
<p>2. Download the source code for the Android application that they offer: <a title="http://www.ibm.com/developerworks/apps/download/index.jsp?contentid=398121&amp;filename=AndroidXml.zip&amp;method=http&amp;locale=worldwide" href="http://www.ibm.com/developerworks/apps/download/index.jsp?contentid=398121&amp;filename=AndroidXml.zip&amp;method=http&amp;locale=worldwide">AndroidXML.zip</a>.</p>
<p>3. Import the project into your Eclipse workspace by right-clicking in Project Explorer and selecting “Import”.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/01import.jpg"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="01 Import" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/01import-thumb.jpg" border="0" alt="01 Import" width="426" height="502" /></a></p>
<p>4. Select “Existing Projects into Workspace”</p>
<p>5. Browse to the directory where you extracted the ZIP file with the source code and then click on the Next buttons to finish off the wizard. The project is called “AndroidXml”.</p>
<p>6. You will now see the project in your workspace:</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/02project.jpg"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="02 project" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/02project-thumb.jpg" border="0" alt="02 project" width="370" height="533" /></a></p>
<p>7. Here is a quick breakdown of what some of those Java classes do:</p>
<p>- MessageList.java is the main activity that gets started. It lists the items from the XML data using a ListActivity. In this project the items come from an RSS feed.</p>
<p>- FeedParser.java, FeedParserFactory.java, BaseFeedParser.java, RSSHandler.hava are all classes that this particular example uses to set the framework for polymorphism.</p>
<p>- This example uses 4 methods for grabbing the XML data and reading it.The 4 methods that this example uses are:</p>
<blockquote><p>1. AndroidSaxFeedParser.java (the default)</p>
<p>2. DomFeedParser.java</p>
<p>3. SaxFeedParser.java</p>
<p>4. XmlPullFeedParser.java</p></blockquote>
<p>These 4 classes all extend BaseFeedParser.java.</p>
<p>8. In order to customize this for your own XML file you need to edit the following places (assuming you are using AndroidSaxFeedParser, which is the default):</p>
<p>- FeedParserFactory.java: you need to change the URL location of the web service or XML document in the global variable here:</p>
<pre class="csharpcode" style="width: 65.22%; height: 29px;"><span class="kwrd">static</span> String feedUrl = <span class="str">"http://www.androidster.com/android_news.rss"</span>;</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>- AndroidSaxFeedParser.java: you need to change the root node of your XML document. This is stored in the String called RSS.</p>
<pre class="csharpcode" style="width: 65.05%; height: 30px;"><span class="kwrd">static</span> final String RSS = <span class="str">"RootNode"</span>;</pre>
<p>- BaseFeedParser.java: you need to change this class according to the nodes that your XML document has.</p>
<p>The nodes CHANNEL and ITEM refer to the nodes &lt;Channel&gt; and &lt;Item&gt; in the RSS feed that this example uses. You need to change them to mimic your nodes from your XML document:</p>
<pre class="csharpcode" style="width: 65%; height: 43px;"><span class="kwrd">static</span> final String CHANNEL = <span class="str">"channel"</span>;
<span class="kwrd">static</span> final  String ITEM = <span class="str">"item"</span>;</pre>
<p>The other constants that are declared refer to the nodes for each repeating item.<br />
<!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<pre class="csharpcode" style="width: 65.28%; height: 83px;"><span class="kwrd">static</span> final  String PUB_DATE = <span class="str">"pubDate"</span>;
<span class="kwrd">static</span> final  String DESCRIPTION = <span class="str">"description"</span>;
<span class="kwrd">static</span> final  String LINK = <span class="str">"link"</span>;
<span class="kwrd">static</span> final  String TITLE = <span class="str">"title"</span>;</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --> <!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>For this particular example, since an RSS feed XML document is used, it has repeating nodes for &lt;Description&gt;, &lt;Link&gt;, &lt;Title&gt;, &lt;PubDate&gt;. You need to change this structure to mimic your structure.</p>
<p>Note: Remember that if you change the name of the constants (as opposed to the value of the constants), you will need to change other classes which call these constants.<br />
<!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>- If you change the names of the constants, you will have to update AndroidSaxFeedParser.java in this section:</p>
<pre class="csharpcode" style="width: 67.45%; height: 343px;">        item.getChild(TITLE).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setTitle(body);
            }
        });
        item.getChild(LINK).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setLink(body);
            }
        });
        item.getChild(DESCRIPTION).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setDescription(body);
            }
        });
        item.getChild(PUB_DATE).setEndTextElementListener(<span class="kwrd">new</span> EndTextElementListener(){
            <span class="kwrd">public</span> <span class="kwrd">void</span> end(String body) {
                currentMessage.setDate(body);
            }
        });</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>As you can see this section is hardcoded for the 4 nodes that are expected in this XML document (TITLE, LINK, DESCRIPTION, PUB_DATE). You will need to change this section and hardcode this for your own nodes.</p>
<p>- If you change the names of the higher-level nodes, i.e. &lt;Channel&gt; and &lt;Item&gt;, then you need to update the following section of AndroidSaxFeedParser.java:</p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<pre class="csharpcode" style="width: 65.08%; height: 49px;">Element itemlist = root.getChild(CHANNEL);
Element item = itemlist.getChild(ITEM);</pre>
<p>And that is all. The customized code will use the AndroidSaxParser implementation of an XML Parser, it will go to the URL you provided in FeedParserFactory.java, and it will iterate through the updated nodes as you have labeled them in BaseFeedParser.java and AndroidSaxFeedParser.java.</p>
<p>In my next post I will provide a simplified version of this code, which does not use polymorphism. It will (hopefully) use the minimum required classes to get XML data and parse it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: Creating TableRow rows inside a TableLayout programatically</title>
		<link>http://www.warriorpoint.com/blog/2009/07/01/android-creating-tablerow-rows-inside-a-tablelayout-programatically/</link>
		<comments>http://www.warriorpoint.com/blog/2009/07/01/android-creating-tablerow-rows-inside-a-tablelayout-programatically/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 02:07:39 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=353</guid>
		<description><![CDATA[In my quest to create a “Taxman” Android application I ran into the following problem:
I want to ask the user to enter their yearly income, after which the screen will flip and their after-tax income will be displayed in a table format for all Canadian provinces. (And for the future: all US states). The problem [...]]]></description>
			<content:encoded><![CDATA[<p>In my quest to create a “Taxman” Android application I ran into the following problem:</p>
<p>I want to ask the user to enter their yearly income, after which the screen will flip and their after-tax income will be displayed in a table format for all Canadian provinces. (And for the future: all US states). The problem I ran into is creating a TableRow for each Canadian province in my main.xml. There are 13 provinces and territories, so 13 is not that bad to copy &amp; paste in the main.xml; however, as soon as I have to copy &amp; paste more than 2 times I start cringing and nausea kicks in. Personally I think “copy &amp; paste” should not be in the programming vocabulary. Not only that, but I have 13 provinces now, what about when I have to enter 50 states! So, I had to find a way to create these new TableRow rows programmatically inside my TableLayout layout.</p>
<p>A great source for code snippets and answers to Android questions is <a title="http://www.anddev.org" href="http://www.anddev.org">http://www.anddev.org</a>. I’m sure if you’re dabbling with Android then you’ve already come across this site. The particular post I read to do this is this one: <a title="http://www.anddev.org/viewtopic.php?p=3404" href="http://www.anddev.org/viewtopic.php?p=3404" target="_blank">Dynamically add rows to TableLayout</a>. Commenters on that post were having problems getting this to work, but after I imported all the correct classes (android.widget.TableRow.LayoutParams is an important one to use) everything worked from the first time. I forced Eclipse to find most of the classes for me.</p>
<p>Below is the code from anddev.org, with my changes for my Taxman Android app. I’m too lazy to do a full-out beginning-to-end tutorial for this code snippet.</p>
<p>First I set my constants at the top of the Activity class:</p>
<pre class="csharpcode" style="width: 65.27%; height: 273px;"><span class="kwrd">public</span> <span class="kwrd">class</span> Activity1 extends Activity implements OnTouchListener{

    <span class="kwrd">int</span> PROVINCE_Alberta = 0;
    <span class="kwrd">int</span> PROVINCE_BC = 1;
    <span class="kwrd">int</span> PROVINCE_Manitoba = 2;
    <span class="kwrd">int</span> PROVINCE_NewBrunswick = 3;
    <span class="kwrd">int</span> PROVINCE_Newfoundland = 4;
    <span class="kwrd">int</span> PROVINCE_Northwest = 5;
    <span class="kwrd">int</span> PROVINCE_NovaScotia = 6;
    <span class="kwrd">int</span> PROVINCE_Nunavut = 7;
    <span class="kwrd">int</span> PROVINCE_Ontario = 8;
    <span class="kwrd">int</span> PROVINCE_PEI = 9;
    <span class="kwrd">int</span> PROVINCE_Quebec = 10;
    <span class="kwrd">int</span> PROVINCE_Saskatchewan = 11;
    <span class="kwrd">int</span> PROVINCE_Yukon = 12;

    <span class="kwrd">int</span> numProvinces = 13;</pre>
<p><span id="more-353"></span></p>
<p>There are 13 of them this time, there will be 50 of them for the States… technically this could be made into something much more malleable like an external config-type XML file.</p>
<p>Then in the onCreate method I created an array of String objects that will house all these provinces:</p>
<pre class="csharpcode" style="width: 65.25%; height: 225px;">        String[] provinces = <span class="kwrd">new</span> String[numProvinces];
        provinces[PROVINCE_Alberta] = <span class="str">"Alberta"</span>;
        provinces[PROVINCE_BC] = <span class="str">"British Columbia"</span>;
        provinces[PROVINCE_Manitoba] = <span class="str">"Manitoba"</span>;
        provinces[PROVINCE_NewBrunswick] = <span class="str">"New Brunswick"</span>;
        provinces[PROVINCE_Newfoundland] = <span class="str">"Newfoundland and Labrador"</span>;
        provinces[PROVINCE_Northwest] = <span class="str">"Northwest Territories"</span>;
        provinces[PROVINCE_NovaScotia] = <span class="str">"Nova Scotia"</span>;
        provinces[PROVINCE_Nunavut] = <span class="str">"Nunavut"</span>;
        provinces[PROVINCE_Ontario] = <span class="str">"Ontario"</span>;
        provinces[PROVINCE_PEI] = <span class="str">"Prince Edward Island"</span>;
        provinces[PROVINCE_Quebec] = <span class="str">"Quebec"</span>;
        provinces[PROVINCE_Saskatchewan] = <span class="str">"Saskatchewan"</span>;
        provinces[PROVINCE_Yukon] =  <span class="str">"Yukon"</span>;</pre>
<p>And right underneath that I create a TableRow for each item in the array provinces:</p>
<pre class="csharpcode" style="width: 65.42%; height: 609px;">        <span class="rem">// Get the TableLayout</span>
        TableLayout tl = (TableLayout) findViewById(R.id.maintable);

        <span class="rem">// Go through each item in the array</span>
        <span class="kwrd">for</span> (<span class="kwrd">int</span> current = 0; current &lt; numProvinces; current++)
        {
            <span class="rem">// Create a TableRow and give it an ID</span>
            TableRow tr = <span class="kwrd">new</span> TableRow(<span class="kwrd">this</span>);
            tr.setId(100+current);
            tr.setLayoutParams(<span class="kwrd">new</span> LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));   

            <span class="rem">// Create a TextView to house the name of the province</span>
            TextView labelTV = <span class="kwrd">new</span> TextView(<span class="kwrd">this</span>);
            labelTV.setId(200+current);
            labelTV.setText(provinces[current]);
            labelTV.setTextColor(Color.BLACK);
            labelTV.setLayoutParams(<span class="kwrd">new</span> LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));
            tr.addView(labelTV);

            <span class="rem">// Create a TextView to house the value of the after-tax income</span>
            TextView valueTV = <span class="kwrd">new</span> TextView(<span class="kwrd">this</span>);
            valueTV.setId(current);
            valueTV.setText(<span class="str">"$0"</span>);
            valueTV.setTextColor(Color.BLACK);
            valueTV.setLayoutParams(<span class="kwrd">new</span> LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));
            tr.addView(valueTV);

            <span class="rem">// Add the TableRow to the TableLayout</span>
            tl.addView(tr, <span class="kwrd">new</span> TableLayout.LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));
        }</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --> <!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>The main.xml contains the following for the TableLayout:</p>
<pre class="csharpcode" style="width: 65.56%; height: 121px;">        &lt;TableLayout xmlns:android=<span class="str">"http://schemas.android.com/apk/res/android"</span>
                android:layout_width=<span class="str">"fill_parent"</span>
                android:layout_height=<span class="str">"fill_parent"</span>
                android:stretchColumns=<span class="str">"0,1"</span>
                android:id=<span class="str">"@+id/maintable"</span> &gt;
        &lt;/TableLayout&gt;</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>And here is the final result:</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/image.png"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="image" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/07/image-thumb.png" border="0" alt="image" width="328" height="625" /></a></p>
<p>So far I have the Ontario taxes working :). If you make $50,000 in Ontario, you’d be taking home $38,285.53.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/07/01/android-creating-tablerow-rows-inside-a-tablelayout-programatically/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: Switching screens by dragging over the touch screen</title>
		<link>http://www.warriorpoint.com/blog/2009/05/29/android-switching-screens-by-dragging-over-the-touch-screen/</link>
		<comments>http://www.warriorpoint.com/blog/2009/05/29/android-switching-screens-by-dragging-over-the-touch-screen/#comments</comments>
		<pubDate>Fri, 29 May 2009 04:17:03 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=345</guid>
		<description><![CDATA[In this post I will show you how to use the touch screen so that you can drag your finger across the screen, and it will switch the screen for you – “iPhone style”!
For this I will be implemented OnTouchListener and overrided the method OnTouch().
To start off, we need to create an Activity with two [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I will show you how to use the touch screen so that you can drag your finger across the screen, and it will switch the screen for you – “iPhone style”!</p>
<p>For this I will be implemented OnTouchListener and overrided the method OnTouch().</p>
<p>To start off, we need to create an Activity with two screens. The two screens will be implemented using a ViewFlipper in the main.xml layout file. Follow the steps in this blog post to set yourself up: <a href="http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/">Android: Switching screens in an Activity with animations (using ViewFlipper)</a>.</p>
<p>1. Now that you have yourself set up, open the Activity1 class.</p>
<p>2. Make the class implement OnTouchListener. The top of the class will look like this:</p>
<pre class="csharpcode" style="width: 65.35%; height: 81px;">...
import android.view.View.OnTouchListener;

<span class="kwrd">public</span> <span class="kwrd">class</span> Activity1 extends Activity implements OnTouchListener{
...</pre>
<p>2. You will have to override the OnTouch() method as well. If you were using eclipse, it might have created the method stub for you:</p>
<pre class="csharpcode" style="width: 65.37%; height: 81px;">    @Override
    <span class="kwrd">public</span> boolean onTouch(View arg0, MotionEvent arg1) {
        <span class="rem">// TODO Auto-generated method stub</span>
        <span class="kwrd">return</span> <span class="kwrd">false</span>;
    }</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>Here is the method that you need to use instead:</p>
<pre class="csharpcode" style="width: 65.43%; height: 471px;">    <span class="kwrd">public</span> boolean onTouch(View arg0, MotionEvent arg1) {

        <span class="rem">// Get the action that was done on this touch event</span>
        <span class="kwrd">switch</span> (arg1.getAction())
        {
            <span class="kwrd">case</span> MotionEvent.ACTION_DOWN:
            {
                <span class="rem">// store the X value when the user's finger was pressed down</span>
                downXValue = arg1.getX();
                <span class="kwrd">break</span>;
            }

            <span class="kwrd">case</span> MotionEvent.ACTION_UP:
            {
                <span class="rem">// Get the X value when the user released his/her finger</span>
                <span class="kwrd">float</span> currentX = arg1.getX();            

                <span class="rem">// going backwards: pushing stuff to the right</span>
                <span class="kwrd">if</span> (downXValue &lt; currentX)
                {
                    <span class="rem">// Get a reference to the ViewFlipper</span>
                     ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                     <span class="rem">// Set the animation</span>
                      vf.setAnimation(AnimationUtils.loadAnimation(<span class="kwrd">this</span>, R.anim.push_left_out));
                      <span class="rem">// Flip!</span>
                      vf.showPrevious();
                }

                <span class="rem">// going forwards: pushing stuff to the left</span>
                <span class="kwrd">if</span> (downXValue &gt; currentX)
                {
                    <span class="rem">// Get a reference to the ViewFlipper</span>
                    ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                     <span class="rem">// Set the animation</span>
                     vf.setInAnimation(AnimationUtils.loadAnimation(<span class="kwrd">this</span>, R.anim.push_left_in));
                      <span class="rem">// Flip!</span>
                     vf.showNext();
                }
                <span class="kwrd">break</span>;
            }
        }

        <span class="rem">// if you return false, these actions will not be recorded</span>
        <span class="kwrd">return</span> <span class="kwrd">true</span>;
    }</pre>
<p>What I’ve done is added a CASE statement. On press down of the finger we save the current X value. On press up of the finger, after the dragging motion has finished, I check the X value again. I compare the two X values and I make a logical decision whether I should switch the screens forwards or backwards.<br />
<!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p><span id="more-345"></span></p>
<p>3. For the above to work, you need to add a global variable called downXValue that will store the X value when the finger was pressed down. Add the line below at the top of the class:</p>
<pre class="csharpcode" style="width: 65.33%; height: 145px;">...
<span class="kwrd">public</span> <span class="kwrd">class</span> Activity1 extends Activity implements OnTouchListener{

    <span class="kwrd">private</span> <span class="kwrd">float</span> downXValue;

    <span class="rem">/** Called when the activity is first created. */</span>
    @Override
    <span class="kwrd">public</span> <span class="kwrd">void</span> onCreate(Bundle savedInstanceState) {
...</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>4. Now, you we will edit the main.xml layout. This is different from the main.xml from the previous post in two ways:</p>
<ul>
<li>The two buttons that switched the views have been removed, because we don’t need them anymore and</li>
<li>I added an ID to the main LinearLayout so that I may reference it in my code.</li>
</ul>
<p>Here is the entire main.xml:</p>
<pre class="csharpcode" style="width: 65.41%; height: 535px;">&lt;?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"utf-8"</span>?&gt;
&lt;LinearLayout xmlns:android=<span class="str">"http://schemas.android.com/apk/res/android"</span>
    android:orientation=<span class="str">"vertical"</span>
    android:layout_width=<span class="str">"fill_parent"</span>
    android:layout_height=<span class="str">"fill_parent"</span>
    android:background=<span class="str">"#ffffff"</span>
    android:id=<span class="str">"@+id/layout_main"</span>
    &gt;

    &lt;ViewFlipper android:id=<span class="str">"@+id/details"</span>
        android:layout_width=<span class="str">"fill_parent"</span>
        android:layout_height=<span class="str">"fill_parent"</span>&gt;  

        &lt;LinearLayout
               android:orientation=<span class="str">"vertical"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"fill_parent"</span>
            android:background=<span class="str">"#ffffff"</span>&gt;

            &lt;TextView android:id=<span class="str">"@+id/tv_country"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"wrap_content"</span>
            android:textColor=<span class="str">"#000000"</span>
            android:textStyle=<span class="str">"bold"</span>
            android:textSize=<span class="str">"18px"</span>
            android:text=<span class="str">"Country"</span> &gt;
            &lt;/TextView&gt;
            &lt;Spinner android:text=<span class="str">""</span>
            android:id=<span class="str">"@+id/spinner_country"</span>
            android:layout_width=<span class="str">"200px"</span>
            android:layout_height=<span class="str">"55px"</span>&gt;
            &lt;/Spinner&gt;
        &lt;/LinearLayout&gt; 

        &lt;LinearLayout
               android:orientation=<span class="str">"vertical"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"fill_parent"</span>
            android:background=<span class="str">"#ffffff"</span>&gt;

            &lt;TextView android:id=<span class="str">"@+id/tv_income"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"wrap_content"</span>
            android:textColor=<span class="str">"#000000"</span>
            android:textStyle=<span class="str">"bold"</span>
            android:textSize=<span class="str">"18px"</span>
            android:text=<span class="str">"Income"</span> &gt;
            &lt;/TextView&gt;
            &lt;EditText android:text=<span class="str">""</span>
            android:id=<span class="str">"@+id/et_income"</span>
            android:layout_width=<span class="str">"200px"</span>
            android:layout_height=<span class="str">"55px"</span>&gt;
            &lt;/EditText&gt;
        &lt;/LinearLayout&gt; 

    &lt;/ViewFlipper&gt;

&lt;/LinearLayout&gt;</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>5. We will have to add a listener for the OnTouch() event in the OnCreate() method of the Activity1 class will be. Add the following two lines:</p>
<pre class="csharpcode" style="width: 65.38%; height: 177px;">...
    <span class="kwrd">public</span> <span class="kwrd">void</span> onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        <span class="rem">// Set main.XML as the layout for this Activity</span>
        setContentView(R.layout.main);

        <span class="rem">// Add these two lines</span>
        LinearLayout layMain = (LinearLayout) findViewById(R.id.layout_main);
        layMain.setOnTouchListener((OnTouchListener) <span class="kwrd">this</span>);
...</pre>
<p>6. You should also remove the two Button OnClick() events and listeners, because those buttons do not exist anymore. Here is the final version of the Activity1.java class:</p>
<pre class="csharpcode" style="width: 65.64%; height: 727px;">package com.warriorpoint.taxman3;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.ViewFlipper;

<span class="kwrd">public</span> <span class="kwrd">class</span> Activity1 extends Activity implements OnTouchListener{

    <span class="kwrd">float</span> downXValue;

    <span class="rem">/** Called when the activity is first created. */</span>
    @Override
    <span class="kwrd">public</span> <span class="kwrd">void</span> onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        <span class="rem">// Set main.XML as the layout for this Activity</span>
        setContentView(R.layout.main);

        <span class="rem">// Add these two lines</span>
        LinearLayout layMain = (LinearLayout) findViewById(R.id.layout_main);
        layMain.setOnTouchListener((OnTouchListener) <span class="kwrd">this</span>); 

        <span class="rem">// Add a few countries to the spinner</span>
        Spinner spinnerCountries = (Spinner) findViewById(R.id.spinner_country);
        ArrayAdapter countryArrayAdapter = <span class="kwrd">new</span> ArrayAdapter(<span class="kwrd">this</span>,
                    android.R.layout.simple_spinner_dropdown_item,
                    <span class="kwrd">new</span> String[] { <span class="str">"Canada"</span>, <span class="str">"USA"</span> });
        spinnerCountries.setAdapter(countryArrayAdapter);

    }

    <span class="kwrd">public</span> boolean onTouch(View arg0, MotionEvent arg1) {

        <span class="rem">// Get the action that was done on this touch event</span>
        <span class="kwrd">switch</span> (arg1.getAction())
        {
            <span class="kwrd">case</span> MotionEvent.ACTION_DOWN:
            {
                <span class="rem">// store the X value when the user's finger was pressed down</span>
                downXValue = arg1.getX();
                <span class="kwrd">break</span>;
            }

            <span class="kwrd">case</span> MotionEvent.ACTION_UP:
            {
                <span class="rem">// Get the X value when the user released his/her finger</span>
                <span class="kwrd">float</span> currentX = arg1.getX();            

                <span class="rem">// going backwards: pushing stuff to the right</span>
                <span class="kwrd">if</span> (downXValue &lt; currentX)
                {
                    <span class="rem">// Get a reference to the ViewFlipper</span>
                     ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                     <span class="rem">// Set the animation</span>
                      vf.setAnimation(AnimationUtils.loadAnimation(<span class="kwrd">this</span>, R.anim.push_left_out));
                      <span class="rem">// Flip!</span>
                      vf.showPrevious();
                }

                <span class="rem">// going forwards: pushing stuff to the left</span>
                <span class="kwrd">if</span> (downXValue &gt; currentX)
                {
                    <span class="rem">// Get a reference to the ViewFlipper</span>
                    ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                     <span class="rem">// Set the animation</span>
                     vf.setInAnimation(AnimationUtils.loadAnimation(<span class="kwrd">this</span>, R.anim.push_left_in));
                      <span class="rem">// Flip!</span>
                     vf.showNext();
                }
                <span class="kwrd">break</span>;
            }
        }

        <span class="rem">// if you return false, these actions will not be recorded</span>
        <span class="kwrd">return</span> <span class="kwrd">true</span>;
    }

}</pre>
<p>That’s it! Run it!</p>
<p>You will see that the button is gone and dragging across to the left or right will switch the screens!</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01animation.jpg"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="01 animation" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01animation-thumb.jpg" border="0" alt="01 animation" width="306" height="583" /></a></p>
<p><strong>Disclaimer: The back animation is not perfect, I still have to figure out why. It flickers a little. If you figure it out to animate properly please drop me a comment. Thanks!</strong></p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/05/29/android-switching-screens-by-dragging-over-the-touch-screen/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: Switching screens in an Activity with animations (using ViewFlipper)</title>
		<link>http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/</link>
		<comments>http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/#comments</comments>
		<pubDate>Wed, 27 May 2009 03:48:05 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=338</guid>
		<description><![CDATA[In this post I’ll show you how to add animations when trying to switch between screens. Usually when you switch between screens it’s a direct “poof” and the new screen appears in a very un-graceful way. The SDK offers a bunch of easy-to-use animations, and I’ll show you how to use them here.
I tried doing [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I’ll show you how to add animations when trying to switch between screens. Usually when you switch between screens it’s a direct “poof” and the new screen appears in a very un-graceful way. The SDK offers a bunch of easy-to-use animations, and I’ll show you how to use them here.</p>
<p>I tried doing animations on the opening and closing of activities, but I haven’t figured that out yet fully. So instead, I will show you how to use animations when switching on objects/layers inside the same activity. It will still look like you are switching screens, but all the layout data will be in one single XML. If we were to switch between activities, each activity would have had (usually) its own layout XML.</p>
<p>And in the post coming after this one, I’ll show you how to start this animation and switch the screen while dragging your fingers on the touch screen. Let me be a little more precise: while dragging one finger on the touch screen. I’m not sure if the OS handles multi-touch right now – or if that’s something the device has to enable – or both.</p>
<p>Back to the topic: how to switch between layers using animations to make it look like you are changing screens… we will be using a ViewFlipper widget in the layout XML.</p>
<p>1. Create a new Android project, unless you already have one</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01newproject1.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="01 new project" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01newproject-thumb1.png" border="0" alt="01 new project" width="458" height="397" /></a></p>
<p>2. Create a new Activity class that extends android.app.Activity.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/02newclass1.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="02 new class" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/02newclass-thumb1.png" border="0" alt="02 new class" width="460" height="354" /></a></p>
<p><span id="more-338"></span></p>
<p>3. Create a new directory under the /res directory and call it anim</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/03resdirectory.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="03 res directory" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/03resdirectory-thumb.png" border="0" alt="03 res directory" width="286" height="229" /></a></p>
<p>4. Right-click on the new directory called anim and Import all the XML files from: Android_SDK\Platform\android-1.5\samples\ApiDemos\res\anim.</p>
<p>These are animations created using XML. The same animations can be created in code, but these are ready for us to use in XML.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/04animdirectory.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="04 anim directory" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/04animdirectory-thumb.png" border="0" alt="04 anim directory" width="292" height="584" /></a></p>
<p>5. Open res\layout\main.xml and copy/paste the following in:</p>
<pre class="csharpcode" style="width: 65.5%; height: 904px;">&lt;?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"utf-8"</span>?&gt;
&lt;LinearLayout xmlns:android=<span class="str">"http://schemas.android.com/apk/res/android"</span>
    android:orientation=<span class="str">"vertical"</span>
    android:layout_width=<span class="str">"fill_parent"</span>
    android:layout_height=<span class="str">"fill_parent"</span>
    android:background=<span class="str">"#ffffff"</span>
    &gt;

    &lt;ViewFlipper android:id=<span class="str">"@+id/details"</span>
        android:layout_width=<span class="str">"fill_parent"</span>
        android:layout_height=<span class="str">"fill_parent"</span>&gt;  

        &lt;LinearLayout
               android:orientation=<span class="str">"vertical"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"fill_parent"</span>
            android:background=<span class="str">"#ffffff"</span>&gt;

            &lt;TextView android:id=<span class="str">"@+id/tv_country"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"wrap_content"</span>
            android:textColor=<span class="str">"#000000"</span>
            android:textStyle=<span class="str">"bold"</span>
            android:textSize=<span class="str">"18px"</span>
            android:text=<span class="str">"Country"</span> &gt;
            &lt;/TextView&gt;
            &lt;Spinner android:text=<span class="str">""</span>
            android:id=<span class="str">"@+id/spinner_country"</span>
            android:layout_width=<span class="str">"200px"</span>
            android:layout_height=<span class="str">"55px"</span>&gt;
            &lt;/Spinner&gt;
            &lt;Button android:text=<span class="str">"Next"</span>
            android:id=<span class="str">"@+id/Button_next"</span>
            android:layout_width=<span class="str">"250px"</span>
                android:textSize=<span class="str">"18px"</span>
            android:layout_height=<span class="str">"55px"</span>&gt;
        &lt;/Button&gt;
        &lt;/LinearLayout&gt; 

        &lt;LinearLayout
               android:orientation=<span class="str">"vertical"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"fill_parent"</span>
            android:background=<span class="str">"#ffffff"</span>&gt;

            &lt;TextView android:id=<span class="str">"@+id/tv_income"</span>
            android:layout_width=<span class="str">"fill_parent"</span>
            android:layout_height=<span class="str">"wrap_content"</span>
            android:textColor=<span class="str">"#000000"</span>
            android:textStyle=<span class="str">"bold"</span>
            android:textSize=<span class="str">"18px"</span>
            android:text=<span class="str">"Income"</span> &gt;
            &lt;/TextView&gt;
            &lt;EditText android:text=<span class="str">""</span>
            android:id=<span class="str">"@+id/et_income"</span>
            android:layout_width=<span class="str">"200px"</span>
            android:layout_height=<span class="str">"55px"</span>&gt;
            &lt;/EditText&gt;
            &lt;Button android:text=<span class="str">"Previous"</span>
            android:id=<span class="str">"@+id/Button_previous"</span>
            android:layout_width=<span class="str">"250px"</span>
                android:textSize=<span class="str">"18px"</span>
            android:layout_height=<span class="str">"55px"</span>&gt;
            &lt;/Button&gt;
        &lt;/LinearLayout&gt; 

    &lt;/ViewFlipper&gt;        

&lt;/LinearLayout&gt;</pre>
<p>This is a little long, let’s inspect it more closely.</p>
<ul>
<li>The outmost layer is a LinearLayout.</li>
<li>It contains only one inner layer: ViewFlipper</li>
<li><strong>The first-level layers inside ViewFlipper will be the screens!</strong>
<ul>
<li>
<ul>
<li>ViewFlipper contains 2 LinearLayouts. Each LinearLayout is 1 screen.</li>
</ul>
</li>
</ul>
</li>
<li>The first LinearLayout contains a label, a spinner (a dropdown), and a button</li>
<li>The second LinearLayout contains a label, an edit view (input box), and a button</li>
</ul>
<p>6. Here is what Activity1.cs looks like:</p>
<pre class="csharpcode" style="width: 65.19%; height: 724px;">package com.warriorpoint.taxman3;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.ViewFlipper;

<span class="kwrd">public</span> <span class="kwrd">class</span> Activity1 extends Activity {
    <span class="rem">/** Called when the activity is first created. */</span>
    @Override
    <span class="kwrd">public</span> <span class="kwrd">void</span> onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        <span class="rem">// Set main.XML as the layout for this Activity</span>
        setContentView(R.layout.main);

        <span class="rem">// Add a few countries to the spinner</span>
        Spinner spinnerCountries = (Spinner) findViewById(R.id.spinner_country);
        ArrayAdapter countryArrayAdapter = <span class="kwrd">new</span> ArrayAdapter(<span class="kwrd">this</span>,
                    android.R.layout.simple_spinner_dropdown_item,
                    <span class="kwrd">new</span> String[] { <span class="str">"Canada"</span>, <span class="str">"USA"</span> });
        spinnerCountries.setAdapter(countryArrayAdapter);

        <span class="rem">// Set the listener for Button_Next, a quick and dirty way to create a listener</span>
        Button buttonNext = (Button) findViewById(R.id.Button_next);
        buttonNext.setOnClickListener(<span class="kwrd">new</span> View.OnClickListener() {
            <span class="kwrd">public</span> <span class="kwrd">void</span> onClick(View view) {
                <span class="rem">// Get the ViewFlipper from the layout</span>
                ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);

                <span class="rem">// Set an animation from res/anim: I pick push left in</span>
                vf.setAnimation(AnimationUtils.loadAnimation(view.getContext(), R.anim.push_left_in));
                vf.showNext();
        }
        });

        <span class="rem">// Set the listener for Button_Previous, a quick and dirty way to create a listener</span>
        Button buttonPrevious = (Button) findViewById(R.id.Button_previous);
        buttonPrevious.setOnClickListener(<span class="kwrd">new</span> View.OnClickListener() {
            <span class="kwrd">public</span> <span class="kwrd">void</span> onClick(View view) {
                <span class="rem">// Get the ViewFlipper from the layout</span>
                ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                <span class="rem">// Set an animation from res/anim: I pick push left out</span>
                vf.setAnimation(AnimationUtils.loadAnimation(view.getContext(), R.anim.push_left_out));
                vf.showPrevious();
        }

        });        

    }
}</pre>
<p>Let’s try and decipher the code:</p>
<ul>
<li>First I set the main.xml to be the layout for this Activity</li>
<li>I input Canada and USA as the values in my dropdown (the Spinner object)</li>
<li>Then I create two listeners for the two buttons that I have Button_next and Button_previous</li>
<li>Each button does the following:
<ul>
<li>
<ul>
<li>Gets a reference to the ViewFlipper</li>
<li>Sets an animation by passing it the context of this class and an animation from a res/anim XML file</li>
<li>showNext() or showPrevious() is called – which literally flips between the LinearLayouts in the ViewFlipper widget in the main.xml either forwards or backwards</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>That’s it! Run it!</p>
<p>Look at that fancy Spinner!</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/05spinner.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="05 spinner" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/05spinner-thumb.png" border="0" alt="05 spinner" width="309" height="558" /></a></p>
<p>Click Next and watch it flow!</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/06animation.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="06 animation" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/06animation-thumb.png" border="0" alt="06 animation" width="294" height="547" /></a></p>
<p><strong>Disclaimer: There is a problem with the back animation when you press “Previous”. It flickers a little and doesn’t flow properly backwards. I still have to figure out why. If anyone knows why, drop me a comment below!</strong></p>
<p>Next up: Removing the “Next” and “Previous” buttons and switching screens by using your finger to drag on the touch screen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: Reading Logs and Exceptions</title>
		<link>http://www.warriorpoint.com/blog/2009/05/24/android-reading-logs-and-exceptions/</link>
		<comments>http://www.warriorpoint.com/blog/2009/05/24/android-reading-logs-and-exceptions/#comments</comments>
		<pubDate>Mon, 25 May 2009 03:21:31 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=322</guid>
		<description><![CDATA[While developing my Android apps I routinely, regularly, almost every time, without a miss, get some kind of exception. And the error you see on screen is not developer friendly, though it is very end-user friendly:

WTF? Why? What did I do wrong this time, again?

You can find the answer very easily:
1. Open a command prompt [...]]]></description>
			<content:encoded><![CDATA[<p>While developing my Android apps I routinely, regularly, almost every time, without a miss, get some kind of exception. And the error you see on screen is not developer friendly, though it is very end-user friendly:</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01error.png"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="01 error" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01error-thumb.png" border="0" alt="01 error" width="279" height="508" /></a></p>
<p>WTF? Why? What did I do wrong this time, again?</p>
<p><span id="more-322"></span></p>
<p>You can find the answer very easily:</p>
<p>1. Open a command prompt window.</p>
<p>2. Go to the SDK_directory\tools\</p>
<p>3. Run “abd logcat”</p>
<p>This will show you all logs that the Android system produces as you click around. Some of the logs will be related to the Exceptions getting thrown because of your app.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/02screen.png"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="02 screen" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/02screen-thumb.png" border="0" alt="02 screen" width="543" height="386" /></a></p>
<p>Null Pointer! But… you still need to decipher where this Null Pointer is from.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/05/24/android-reading-logs-and-exceptions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Android: How to switch between Activities</title>
		<link>http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/</link>
		<comments>http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/#comments</comments>
		<pubDate>Mon, 25 May 2009 02:38:21 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=308</guid>
		<description><![CDATA[In my great expectations of Google Android coming to Canada on June 2nd, I’ve started experimenting with developing some apps for the Android platform. My first app is called “The Taxman” and will calculate the amount of tax you owe per year in your province/state – well only Canada for now.
I had trouble adjusting to [...]]]></description>
			<content:encoded><![CDATA[<p>In my great expectations of Google Android coming to Canada on June 2nd, I’ve started experimenting with developing some apps for the Android platform. My first app is called “The Taxman” and will calculate the amount of tax you owe per year in your province/state – well only Canada for now.</p>
<p>I had trouble adjusting to what an “Activity” was and how to handle it. Here is a quick and dirty way to create an Activity, and to switch to another Activity (think of it as another screen) on the click of a button.</p>
<p>1. Create a new Android project – or you might already have one created.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01newproject.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="01 new project" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/01newproject-thumb.png" border="0" alt="01 new project" width="400" height="347" /></a></p>
<p>2. Add a new Class that extends android.app.Activity. You need a total of two classes that extend Activity. You will switch from one Activity to another.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/02newclass.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="02 new class" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/02newclass-thumb.png" border="0" alt="02 new class" width="401" height="309" /></a></p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/03newclass2.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="03 new class 2" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/03newclass2-thumb.png" border="0" alt="03 new class 2" width="402" height="475" /></a></p>
<p><span id="more-308"></span></p>
<p>3. Now, we’ll create two XML files to store the layout of each Activity. Under the res/layouts directory create a copy of main.xml</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/04xmlfiles.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="04 xml files" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/04xmlfiles-thumb.png" border="0" alt="04 xml files" width="413" height="379" /></a></p>
<p>4. Each XML file will contain 1 button. On the click of the button, the Activities will switch.</p>
<p>main.xml will contain:</p>
<pre class="csharpcode" style="width: 65.54%; height: 355px;">&lt;?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"utf-8"</span>?&gt;
&lt;LinearLayout xmlns:android=<span class="str">"http://schemas.android.com/apk/res/android"</span>
    android:orientation=<span class="str">"vertical"</span>
    android:layout_width=<span class="str">"fill_parent"</span>
    android:layout_height=<span class="str">"fill_parent"</span>
    android:background=<span class="str">"#ffffff"</span>  &gt;

    &lt;TextView
    android:layout_width=<span class="str">"fill_parent"</span>
    android:layout_height=<span class="str">"wrap_content"</span>
    android:textColor=<span class="str">"#000000"</span>
    android:text=<span class="str">"This is Activity 1"</span> /&gt;

       &lt;Button android:text=<span class="str">"Next"</span>
        android:id=<span class="str">"@+id/Button01"</span>
        android:layout_width=<span class="str">"250px"</span>
            android:textSize=<span class="str">"18px"</span>
        android:layout_height=<span class="str">"55px"</span>&gt;
    &lt;/Button&gt;    

&lt;/LinearLayout&gt;</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>main2.xml will contain:</p>
<pre class="csharpcode" style="width: 65.38%; height: 355px;">&lt;?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"utf-8"</span>?&gt;
&lt;LinearLayout xmlns:android=<span class="str">"http://schemas.android.com/apk/res/android"</span>
    android:orientation=<span class="str">"vertical"</span>
    android:layout_width=<span class="str">"fill_parent"</span>
    android:layout_height=<span class="str">"fill_parent"</span>
    android:background=<span class="str">"#ffffff"</span>  &gt;

    &lt;TextView
    android:layout_width=<span class="str">"fill_parent"</span>
    android:layout_height=<span class="str">"wrap_content"</span>
    android:textColor=<span class="str">"#000000"</span>
    android:text=<span class="str">"This is Activity 2"</span> /&gt;

       &lt;Button android:text=<span class="str">"Previous"</span>
        android:id=<span class="str">"@+id/Button02"</span>
        android:layout_width=<span class="str">"250px"</span>
            android:textSize=<span class="str">"18px"</span>
        android:layout_height=<span class="str">"55px"</span>&gt;
    &lt;/Button&gt;    

&lt;/LinearLayout&gt;</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>So each Activity will have a text that says “This is Activity x” and a button to switch the Activity.</p>
<p>5. Add the second Activity to the main manifest file. Open AndroidManifest.xml and add:</p>
<pre class="csharpcode" style="width: 65.26%; height: 19px;">        &lt;activity android:name=<span class="str">".Activity2"</span>&gt;&lt;/activity&gt;</pre>
<p>The final result will look similar to this:</p>
<pre class="csharpcode" style="width: 65.5%; height: 275px;">&lt;?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"utf-8"</span>?&gt;
&lt;manifest xmlns:android=<span class="str">"http://schemas.android.com/apk/res/android"</span>
      package=<span class="str">"com.warriorpoint.taxman2"</span>
      android:versionCode=<span class="str">"1"</span>
      android:versionName=<span class="str">"1.0"</span>&gt;
    &lt;application android:icon=<span class="str">"@drawable/icon"</span> android:label=<span class="str">"@string/app_name"</span>&gt;
        &lt;activity android:name=<span class="str">".Activity1"</span>
                  android:label=<span class="str">"@string/app_name"</span>&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=<span class="str">"android.intent.action.MAIN"</span> /&gt;
                &lt;category android:name=<span class="str">"android.intent.category.LAUNCHER"</span> /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity android:name=<span class="str">".Activity2"</span>&gt;&lt;/activity&gt;
    &lt;/application&gt;
    &lt;uses-sdk android:minSdkVersion=<span class="str">"3"</span> /&gt;
&lt;/manifest&gt;</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>If you forget to do this, then the you will get a Null Pointer exception because “Activity2” will not be found at runtime. It took me some time to find out how to find what Exception was getting thrown as well. I will include how to debug and look at Exceptions in another future post.</p>
<p>5. Open Activity1.java and enter the following code:</p>
<pre class="csharpcode" style="width: 65.48%; height: 401px;">package com.warriorpoint.taxman2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

<span class="kwrd">public</span> <span class="kwrd">class</span> Activity1 extends Activity {
    <span class="rem">/** Called when the activity is first created. */</span>
    @Override
    <span class="kwrd">public</span> <span class="kwrd">void</span> onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button next = (Button) findViewById(R.id.Button01);
        next.setOnClickListener(<span class="kwrd">new</span> View.OnClickListener() {
            <span class="kwrd">public</span> <span class="kwrd">void</span> onClick(View view) {
                Intent myIntent = <span class="kwrd">new</span> Intent(view.getContext(), Activity2.<span class="kwrd">class</span>);
                startActivityForResult(myIntent, 0);
            }

        });
    }
}</pre>
<p>Here’s a quick explanation of what this does:</p>
<p>- setContentView(R.layout.main) makes sure that main.xml is used as the layout for this Activity.</p>
<p>- Gets a reference to the button with ID Button01 on the layout using (Button) findViewById(R.id.Button01).</p>
<p>- Create san OnClick listener for the button – a quick and dirty way.</p>
<p>- And the most important part, creates an “Intent” to start another Activity. The intent needs two parameters: a context and the name of the Activity that we want to start (Activity2.class)</p>
<p>- Finally, the Activity is started with a code of “0”. The “0” is your own code for whatever you want it to mean. Activity2 will get a chance to read this code and use it. startActivityForResult means that Activity1 can expect info back from Activity2. The result from Activity2 will be gathered in a separate method which I will not include here.</p>
<p>6. Open Activity2.java and enter the code below:</p>
<pre class="csharpcode" style="width: 65.4%; height: 401px;">package com.warriorpoint.taxman2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

<span class="kwrd">public</span> <span class="kwrd">class</span> Activity2 extends Activity {

    <span class="rem">/** Called when the activity is first created. */</span>
    <span class="kwrd">public</span> <span class="kwrd">void</span> onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main2);

        Button next = (Button) findViewById(R.id.Button02);
        next.setOnClickListener(<span class="kwrd">new</span> View.OnClickListener() {
            <span class="kwrd">public</span> <span class="kwrd">void</span> onClick(View view) {
                Intent intent = <span class="kwrd">new</span> Intent();
                setResult(RESULT_OK, intent);
                finish();
            }

        });
    }</pre>
<p>This code does the following:</p>
<p>- Sets main2 as the layout for this Activity</p>
<p>- Gets a reference to Button02 and creates an OnClick listener</p>
<p>- In the OnClick listener, the Activity finishes with finish(). setResult() returns information back to Activity 1. In this example, it returns no information; and Activity1 doesn’t even have the listener to receive this information anyway.</p>
<p>That’s it! Run it!</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/05run.png"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="05 run" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/05run-thumb.png" border="0" alt="05 run" width="419" height="419" /></a></p>
<p>The app will load in Activity 1:</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/06activity1.png"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="06 activity 1" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/06activity1-thumb.png" border="0" alt="06 activity 1" width="256" height="466" /></a></p>
<p>When you click the button you will see Activity 2. There are no animations, no tweens, etc, so the screen will just “change”. I’ll talk about animations in future posts.</p>
<p><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/07activity2.png"><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="07 activity 2" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/07activity2-thumb.png" border="0" alt="07 activity 2" width="255" height="471" /></a></p>
<p>And clicking on the button “Previous” here will go back to Activity1.</p>
<p>Still to come:</p>
<p>1. How to create animations when switching screens.</p>
<p>2. How to switch using a dragging motion of your finger.</p>
<p>3. How to see a log of the exceptions that your app throws.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/05/24/android-how-to-switch-between-activities/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Developer&#8217;s Perspective on Android: Getting Started</title>
		<link>http://www.warriorpoint.com/blog/2009/05/24/developers-perspective-on-android-getting-started/</link>
		<comments>http://www.warriorpoint.com/blog/2009/05/24/developers-perspective-on-android-getting-started/#comments</comments>
		<pubDate>Mon, 25 May 2009 01:49:15 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[Android]]></category>

		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=297</guid>
		<description><![CDATA[
I’ve been a fan of Google’s mobile operating system Android for quite a while – technically since I heard about it 2 years ago. I’ve been unfortunate to live in Canada, because none of the telco companies here have carried any phones with Android (only HTC phones for now, but Samsung seems to be coming [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_298" class="wp-caption alignleft" style="width: 310px"><a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/500px-android-logo_svg.png"><img class="size-medium wp-image-298" title="Google Android" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/05/500px-android-logo_svg-300x300.png" alt="Google Android" width="300" height="300" /></a><p class="wp-caption-text"> </p></div></p>
<p>I’ve been a fan of Google’s mobile operating system Android for quite a while – technically since I heard about it 2 years ago. I’ve been unfortunate to live in Canada, because none of the telco companies here have carried any phones with Android (only HTC phones for now, but Samsung seems to be coming out with something soon).</p>
<p>But, on June 2nd 2009 Rogers is coming out with the HTC Dream and the HTC Magic and Google Android will be here! And on June 3rd Google Android will be in my hands. [I’m not going to be a geek and get it on the very <em>first</em> day it comes out, come on!]</p>
<p>So, in expectation of this date, I started playing around with Android and developing my own applications. To start off, it’s been absolutely easy, pleasant, and a breeze to setup. It was like stealing candy from a kid. I followed the instructions from the Android – Developers website and using Eclipse as my environment I was creating mobile applications in less than 30 mins.</p>
<p>To get the SDK follow this link: <a title="http://developer.android.com/sdk/1.5_r2/index.html" href="http://developer.android.com/sdk/1.5_r2/index.html">http://developer.android.com/sdk/1.5_r2/index.html</a><br />
To read the installation instructions follow this link: <a title="http://developer.android.com/sdk/1.5_r2/installing.html" href="http://developer.android.com/sdk/1.5_r2/installing.html">http://developer.android.com/sdk/1.5_r2/installing.html</a><br />
And I recommend using Eclipse if you do want to get the “30 mins effect”.</p>
<p>I wanted to test out the different functions/features that Android offers out of the box, so I thought of a simple app which would allow me to have a goal and thus opportunities to experiment. I am going to write a “tax” application. Unfortunately, this tax application will not fill out your taxes. It will calculate how much the government has to take from you each year. You will enter your country (Canada only for now), you will enter your income, and the result will be a summary of your take-home pay and taxes due, by province (or states for the US – eventually). I’m going to call it “The Taxman”.</p>
<p>I’ve just started this mini app, and as I go along I will post snippets of code that I found difficult to come up with – to help out anyone that is looking for the exact same solution. Also, I have a full-time job, so it will take me a month to complete this silly app :), so my posts might be infrequent.</p>
<p>This weekend I had a chance to start it off and I had trouble with a couple of things. I will write a separate post on each one over the next couple of weeks. Here’s three of those things:</p>
<p>1. How to switch from one screen to another (also called Activities)</p>
<p>2. How to switch screens with an animation effect</p>
<p>3. How to switch screens using a dragging motion with your finger – you know, iPhone stylez.</p>
<p>That’s it for now… those 3 posts will be coming out very, very soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/05/24/developers-perspective-on-android-getting-started/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Checking up on the On-Demand Index</title>
		<link>http://www.warriorpoint.com/blog/2009/01/31/checking-up-on-the-on-demand-index/</link>
		<comments>http://www.warriorpoint.com/blog/2009/01/31/checking-up-on-the-on-demand-index/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 02:41:26 +0000</pubDate>
		<dc:creator>Boyan</dc:creator>
		
		<category><![CDATA[On-Demand Index]]></category>

		<guid isPermaLink="false">http://www.warriorpoint.com/blog/?p=266</guid>
		<description><![CDATA[I decided to get off my lazy butt, after 3 months of non-posts, and check up on something. Some time ago I wrote a post about an &#8220;On-Demand Index&#8221;. This was a portfolio of On-Demand/SaaS stocks picked by Rick Sherman on SeekingAlpha.com. I created some AJAX scripts that took data from Google Finance for that [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to get off my lazy butt, after 3 months of non-posts, and check up on something. Some time ago I wrote a post about an <a href="http://www.warriorpoint.com/blog/2008/07/11/saas-stocks-the-on-demand-index-is-now-dynamic-and-up-to-date/" target="_blank">&#8220;On-Demand Index&#8221;</a>. This was a portfolio of On-Demand/SaaS stocks picked by Rick Sherman on SeekingAlpha.com. I created some AJAX scripts that took data from Google Finance for that portfolio and made it into <a href="http://www.warriorpoint.com/blog/on-demand-index/" target="_blank">a page on this blog</a>. I thought, this way you can always go to that page and see overall how the SaaS stocks are doing in real-time.</p>
<p>Well, here I am, half a year later, trying to find out what happened to those stocks.</p>
<p>This is the original chart from June 29th 2008 that got me started:<br />
<a href="http://www.warriorpoint.com/blog/wp-content/uploads/2009/01/junestocks.bmp"><img class="alignnone size-medium wp-image-268" title="junestocks" src="http://www.warriorpoint.com/blog/wp-content/uploads/2009/01/junestocks.bmp" alt="On-Demand index June 29th" /></a></p>
<p>This is the chart on January 1st 2009, from the On-Demand Index page:</p>
<table border="1">
<tbody>
<tr style="font-weight: bold; background-color: #ffcc33;">
<td id="Td13">Company</td>
<td id="Td14">Symbol</td>
<td id="Td15" align="right">Return since Jan</td>
<td id="Td16" align="right">Return last 1 year</td>
<td id="Td17" align="right">Latest Price</td>
<td id="Td18" align="right">52 High</td>
<td id="Td19" align="right">52 Low</td>
<td id="Td20" align="right">EPS</td>
<td id="Td21" align="right">P/E</td>
<td id="Td22" align="right">Market Cap</td>
</tr>
<tr>
<td id="ATHN_Name">athenahealth, Inc.</td>
<td id="ATHN_Symbol"><a href="http://finance.google.com/finance?q=ATHN&amp;hl=en" target="_blank">ATHN</a></td>
<td id="ATHN_Price" align="right">1.32%</td>
<td id="ATHN_MarketCap" align="right">8.54%</td>
<td id="ATHN_PE" align="right">36.08</td>
<td id="ATHN_High52" align="right">39.29</td>
<td id="ATHN_Low52" align="right">19.19</td>
<td id="ATHN_EPS" align="right">0.30</td>
<td id="ATHN_ReturnJan" align="right">118.56</td>
<td id="ATHN_ReturnYear" align="right">1.20B</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="BBBB_Name">Blackboard, Inc.</td>
<td id="BBBB_Symbol"><a href="http://finance.google.com/finance?q=BBBB&amp;hl=en" target="_blank">BBBB</a></td>
<td id="BBBB_Price" style="color: red;" align="right">-5.15%</td>
<td id="BBBB_MarketCap" style="color: red;" align="right">-27.17%</td>
<td id="BBBB_PE" align="right">25.41</td>
<td id="BBBB_High52" align="right">45.00</td>
<td id="BBBB_Low52" align="right">19.36</td>
<td id="BBBB_EPS" align="right">0.13</td>
<td id="BBBB_ReturnJan" align="right">199.39</td>
<td id="BBBB_ReturnYear" align="right">796.66M</td>
</tr>
<tr>
<td id="CNQR_Name">Concur Technologies, Inc.</td>
<td id="CNQR_Symbol"><a href="http://finance.google.com/finance?q=CNQR&amp;hl=en" target="_blank">CNQR</a></td>
<td id="CNQR_Price" style="color: red;" align="right">-26.03%</td>
<td id="CNQR_MarketCap" style="color: red;" align="right">-32.19%</td>
<td id="CNQR_PE" align="right">24.69</td>
<td id="CNQR_High52" align="right">50.00</td>
<td id="CNQR_Low52" align="right">19.52</td>
<td id="CNQR_EPS" align="right">0.35</td>
<td id="CNQR_ReturnJan" align="right">69.91</td>
<td id="CNQR_ReturnYear" align="right">1.21B</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="CRM_Name">salesforce.com, Inc.</td>
<td id="CRM_Symbol"><a href="http://finance.google.com/finance?q=CRM&amp;hl=en" target="_blank">CRM</a></td>
<td id="CRM_Price" style="color: red;" align="right">-21.78%</td>
<td id="CRM_MarketCap" style="color: red;" align="right">-48.55%</td>
<td id="CRM_PE" align="right">26.61</td>
<td id="CRM_High52" align="right">75.21</td>
<td id="CRM_Low52" align="right">20.82</td>
<td id="CRM_EPS" align="right">0.30</td>
<td id="CRM_ReturnJan" align="right">89.61</td>
<td id="CRM_ReturnYear" align="right">3.25B</td>
</tr>
<tr>
<td id="CTCT_Name">Constant Contact, Inc.</td>
<td id="CTCT_Symbol"><a href="http://finance.google.com/finance?q=CTCT&amp;hl=en" target="_blank">CTCT</a></td>
<td id="CTCT_Price" align="right">10.01%</td>
<td id="CTCT_MarketCap" style="color: red;" align="right">-26.02%</td>
<td id="CTCT_PE" align="right">15.27</td>
<td id="CTCT_High52" align="right">21.84</td>
<td id="CTCT_Low52" align="right">0.01</td>
<td id="CTCT_EPS" style="color: red;" align="right">-0.06</td>
<td id="CTCT_ReturnJan" align="right">-</td>
<td id="CTCT_ReturnYear" align="right">429.46M</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="DMAN_Name">DemandTec, Inc.</td>
<td id="DMAN_Symbol"><a href="http://finance.google.com/finance?q=DMAN&amp;hl=en" target="_blank">DMAN</a></td>
<td id="DMAN_Price" style="color: red;" align="right">-22.27%</td>
<td id="DMAN_MarketCap" style="color: red;" align="right">-44.67%</td>
<td id="DMAN_PE" align="right">6.70</td>
<td id="DMAN_High52" align="right">13.10</td>
<td id="DMAN_Low52" align="right">5.77</td>
<td id="DMAN_EPS" style="color: red;" align="right">-0.17</td>
<td id="DMAN_ReturnJan" align="right">-</td>
<td id="DMAN_ReturnYear" align="right">186.47M</td>
</tr>
<tr>
<td id="KNXA_Name">Kenexa Corporation</td>
<td id="KNXA_Symbol"><a href="http://finance.google.com/finance?q=KNXA&amp;hl=en" target="_blank">KNXA</a></td>
<td id="KNXA_Price" style="color: red;" align="right">-10.78%</td>
<td id="KNXA_MarketCap" style="color: red;" align="right">-62.05%</td>
<td id="KNXA_PE" align="right">6.79</td>
<td id="KNXA_High52" align="right">24.01</td>
<td id="KNXA_Low52" align="right">4.68</td>
<td id="KNXA_EPS" align="right">0.94</td>
<td id="KNXA_ReturnJan" align="right">7.24</td>
<td id="KNXA_ReturnYear" align="right">153.18M</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="LOOP_Name">LoopNet, Inc.</td>
<td id="LOOP_Symbol"><a href="http://finance.google.com/finance?q=LOOP&amp;hl=en" target="_blank">LOOP</a></td>
<td id="LOOP_Price" style="color: red;" align="right">-6.07%</td>
<td id="LOOP_MarketCap" style="color: red;" align="right">-56.35%</td>
<td id="LOOP_PE" align="right">6.50</td>
<td id="LOOP_High52" align="right">15.48</td>
<td id="LOOP_Low52" align="right">4.75</td>
<td id="LOOP_EPS" align="right">0.52</td>
<td id="LOOP_ReturnJan" align="right">12.56</td>
<td id="LOOP_ReturnYear" align="right">222.78M</td>
</tr>
<tr>
<td id="N_Name">Netsuite Inc</td>
<td id="N_Symbol"><a href="http://finance.google.com/finance?q=N&amp;hl=en" target="_blank">N</a></td>
<td id="N_Price" style="color: red;" align="right">-16.67%</td>
<td id="N_MarketCap" style="color: red;" align="right">-74.22%</td>
<td id="N_PE" align="right">7.00</td>
<td id="N_High52" align="right">28.84</td>
<td id="N_Low52" align="right">5.43</td>
<td id="N_EPS" style="color: red;" align="right">-0.40</td>
<td id="N_ReturnJan" align="right">-</td>
<td id="N_ReturnYear" align="right">425.85M</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="OMTR_Name">Omniture, Inc.</td>
<td id="OMTR_Symbol"><a href="http://finance.google.com/finance?q=OMTR&amp;hl=en" target="_blank">OMTR</a></td>
<td id="OMTR_Price" style="color: red;" align="right">-17.51%</td>
<td id="OMTR_MarketCap" style="color: red;" align="right">-66.58%</td>
<td id="OMTR_PE" align="right">9.09</td>
<td id="OMTR_High52" align="right">28.00</td>
<td id="OMTR_Low52" align="right">7.15</td>
<td id="OMTR_EPS" style="color: red;" align="right">-0.55</td>
<td id="OMTR_ReturnJan" align="right">-</td>
<td id="OMTR_ReturnYear" align="right">662.94M</td>
</tr>
<tr>
<td id="RNOW_Name">RightNow Technologies</td>
<td id="RNOW_Symbol"><a href="http://finance.google.com/finance?q=RNOW&amp;hl=en" target="_blank">RNOW</a></td>
<td id="RNOW_Price" style="color: red;" align="right">-30.48%</td>
<td id="RNOW_MarketCap" style="color: red;" align="right">-50.47%</td>
<td id="RNOW_PE" align="right">5.84</td>
<td id="RNOW_High52" align="right">17.39</td>
<td id="RNOW_Low52" align="right">5.02</td>
<td id="RNOW_EPS" style="color: red;" align="right">-0.34</td>
<td id="RNOW_ReturnJan" align="right">-</td>
<td id="RNOW_ReturnYear" align="right">195.66M</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="SFSF_Name">SuccessFactors, Inc.</td>
<td id="SFSF_Symbol"><a href="http://finance.google.com/finance?q=SFSF&amp;hl=en" target="_blank">SFSF</a></td>
<td id="SFSF_Price" align="right">16.64%</td>
<td id="SFSF_MarketCap" style="color: red;" align="right">-26.04%</td>
<td id="SFSF_PE" align="right">6.73</td>
<td id="SFSF_High52" align="right">15.00</td>
<td id="SFSF_Low52" align="right">4.61</td>
<td id="SFSF_EPS" style="color: red;" align="right">-1.64</td>
<td id="SFSF_ReturnJan" align="right">-</td>
<td id="SFSF_ReturnYear" align="right">377.61M</td>
</tr>
<tr>
<td id="SLRY_Name">Salary.com, Inc.</td>
<td id="SLRY_Symbol"><a href="http://finance.google.com/finance?q=SLRY&amp;hl=en" target="_blank">SLRY</a></td>
<td id="SLRY_Price" style="color: red;" align="right">-32.95%</td>
<td id="SLRY_MarketCap" style="color: red;" align="right">-81.37%</td>
<td id="SLRY_PE" align="right">1.77</td>
<td id="SLRY_High52" align="right">11.00</td>
<td id="SLRY_Low52" align="right">1.40</td>
<td id="SLRY_EPS" style="color: red;" align="right">-1.32</td>
<td id="SLRY_ReturnJan" align="right">-</td>
<td id="SLRY_ReturnYear" align="right">29.09M</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="TLEO_Name">Taleo Corporation</td>
<td id="TLEO_Symbol"><a href="http://finance.google.com/finance?q=TLEO&amp;hl=en" target="_blank">TLEO</a></td>
<td id="TLEO_Price" align="right">5.24%</td>
<td id="TLEO_MarketCap" style="color: red;" align="right">-61.7%</td>
<td id="TLEO_PE" align="right">8.43</td>
<td id="TLEO_High52" align="right">26.16</td>
<td id="TLEO_Low52" align="right">5.37</td>
<td id="TLEO_EPS" style="color: red;" align="right">-0.08</td>
<td id="TLEO_ReturnJan" align="right">-</td>
<td id="TLEO_ReturnYear" align="right">258.04M</td>
</tr>
<tr>
<td id="TRAK_Name">DealerTrack Holdings, Inc.</td>
<td id="TRAK_Symbol"><a href="http://finance.google.com/finance?q=TRAK&amp;hl=en" target="_blank">TRAK</a></td>
<td id="TRAK_Price" style="color: red;" align="right">-7.7%</td>
<td id="TRAK_MarketCap" style="color: red;" align="right">-59.75%</td>
<td id="TRAK_PE" align="right">11.39</td>
<td id="TRAK_High52" align="right">28.75</td>
<td id="TRAK_Low52" align="right">8.84</td>
<td id="TRAK_EPS" align="right">0.16</td>
<td id="TRAK_ReturnJan" align="right">72.46</td>
<td id="TRAK_ReturnYear" align="right">453.67M</td>
</tr>
<tr>
<td id="ULTI_Name">The Ultimate Software Group</td>
<td id="ULTI_Symbol"><a href="http://finance.google.com/finance?q=ULTI&amp;hl=en" target="_blank">ULTI</a></td>
<td id="ULTI_Price" style="color: red;" align="right">-14.15%</td>
<td id="ULTI_MarketCap" style="color: red;" align="right">-52.7%</td>
<td id="ULTI_PE" align="right">13.77</td>
<td id="ULTI_High52" align="right">41.68</td>
<td id="ULTI_Low52" align="right">10.70</td>
<td id="ULTI_EPS" align="right">0.72</td>
<td id="ULTI_ReturnJan" align="right">19.16</td>
<td id="ULTI_ReturnYear" align="right">336.52M</td>
</tr>
<tr style="background-color: #e6e6e6;">
<td id="VOCS_Name">Vocus, Inc.</td>
<td id="VOCS_Symbol"><a href="http://finance.google.com/finance?q=VOCS&amp;hl=en" target="_blank">VOCS</a></td>
<td id="VOCS_Price" style="color: red;" align="right">-19%</td>
<td id="VOCS_MarketCap" style="color: red;" align="right">-48.86%</td>
<td id="VOCS_PE" align="right">15.26</td>
<td id="VOCS_High52" align="right">41.50</td>
<td id="VOCS_Low52" align="right">12.90</td>
<td id="VOCS_EPS" align="right">0.31</td>
<td id="VOCS_ReturnJan" align="right">48.50</td>
<td id="VOCS_ReturnYear" align="right">290.29M</td>
</tr>
<tr style="font-weight: bold; background-color: #ffcc33;">
<td id="TOTAL_Name">TOTAL</td>
<td id="TOTAL_Symbol"> </td>
<td id="TOTAL_RunningJan" style="color: red;" align="right">-11.61%</td>
<td id="TOTAL_RunningYear" style="color: red;" align="right">-47.66%</td>
<td id="TOTAL_PE"> </td>
<td id="TOTAL_High52"> </td>
<td id="TOTAL_Low52"> </td>
<td id="TOTAL_EPS"> </td>
<td id="TOTAL_ReturnJan"> </td>
<td id="TOTAL_ReturnYear"> </td>
</tr>
</tbody>
</table>
<p>Yikes! The return over the last year is -47%! The return since Jan 1 is -11%!</p>
<p>There is only ONE company on that list that has posted an increase in the past half year,<br />
<strong>athenahealth (ATHN)<br />
</strong>June 2008: 30.2<br />
January 2009: 36.08<br />
%: 19.47%</p>
<p>All the others are in the red, with an honourable mention going to<br />
<strong>Salesforce.com (CRM)</strong><br />
June 2008: 68.6<br />
January 2009: 26.61<br />
%: -61.2%</p>
<p>Here&#8217;s a complete listing of the changes since June 2008:</p>
<table style="width: 600px;" border="1">
<tbody>
<tr style="background-color:#FFCC33; font-weight:bold; ">
<td id="Td13">Company</td>
<td id="Td14" width="100">Symbol</td>
<td id="Td15" width="70" align="right">Jun-08</td>
<td id="Td16" width="70" align="right">Jan-09</td>
<td id="Td17" width="70" align="right">%</td>
</tr>
<tr>
<td id="ATHN_Name">athenahealth, Inc.</td>
<td id="ATHN_Symbol"><a href="http://finance.google.com/finance?q=ATHN&amp;hl=en" target="_blank">ATHN</a></td>
<td id="ATHN_Price" style="TEXT-ALIGN: right">30.2</td>
<td id="ATHN_MarketCap" style="text-align: right;"> 36.08</td>
<td id="ATHN_PE" style="text-align: right;"> 19.47</td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="BBBB_Name">Blackboard, Inc.</td>
<td id="BBBB_Symbol"><a href="http://finance.google.com/finance?q=BBBB&amp;hl=en" target="_blank">BBBB</a></td>
<td id="BBBB_Price" style="TEXT-ALIGN: right">39.4</td>
<td id="BBBB_MarketCap" style="text-align: right;"> 25.41</td>
<td id="BBBB_PE" style="text-align: right;"><span style="color: #ff0000;"> -35.51</span></td>
</tr>
<tr>
<td id="CNQR_Name">Concur Technologies, Inc.</td>
<td id="CNQR_Symbol"><a href="http://finance.google.com/finance?q=CNQR&amp;hl=en" target="_blank">CNQR</a></td>
<td id="CNQR_Price" style="TEXT-ALIGN: right">34.3</td>
<td id="CNQR_MarketCap" style="text-align: right;"> 24.69</td>
<td id="CNQR_PE" style="text-align: right;"><span style="color: #ff0000;"> -28.02</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="CRM_Name">salesforce.com, Inc.</td>
<td id="CRM_Symbol"><a href="http://finance.google.com/finance?q=CRM&amp;hl=en" target="_blank">CRM</a></td>
<td id="CRM_Price" style="TEXT-ALIGN: right">68.6</td>
<td id="CRM_MarketCap" style="text-align: right;"> 26.61</td>
<td id="CRM_PE" style="text-align: right;"><span style="color: #ff0000;"> -62.21</span></td>
</tr>
<tr>
<td id="CTCT_Name">Constant Contact, Inc.</td>
<td id="CTCT_Symbol"><a href="http://finance.google.com/finance?q=CTCT&amp;hl=en" target="_blank">CTCT</a></td>
<td id="CTCT_Price" style="TEXT-ALIGN: right">19</td>
<td id="CTCT_MarketCap" style="text-align: right;"> 15.27</td>
<td id="CTCT_PE" style="text-align: right;"> <span style="color: #ff0000;">-19.63</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="DMAN_Name">DemandTec, Inc.</td>
<td id="DMAN_Symbol"><a href="http://finance.google.com/finance?q=DMAN&amp;hl=en" target="_blank">DMAN</a></td>
<td id="DMAN_Price" style="TEXT-ALIGN: right">7.93</td>
<td id="DMAN_MarketCap" style="text-align: right;"> 6.7</td>
<td id="DMAN_PE" style="text-align: right;"> <span style="color: #ff0000;">-15.51</span></td>
</tr>
<tr>
<td id="KNXA_Name">Kenexa Corporation</td>
<td id="KNXA_Symbol"><a href="http://finance.google.com/finance?q=KNXA&amp;hl=en" target="_blank">KNXA</a></td>
<td id="KNXA_Price" style="TEXT-ALIGN: right">19.7</td>
<td id="KNXA_MarketCap" style="text-align: right;"> 6.79</td>
<td id="KNXA_PE" style="text-align: right;"><span style="color: #ff0000;"> -65.53</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="LOOP_Name">LoopNet, Inc.</td>
<td id="LOOP_Symbol"><a href="http://finance.google.com/finance?q=LOOP&amp;hl=en" target="_blank">LOOP</a></td>
<td id="LOOP_Price" style="TEXT-ALIGN: right">11.1</td>
<td id="LOOP_MarketCap" style="text-align: right;"> 6.5</td>
<td id="LOOP_PE" style="text-align: right;"><span style="color: #ff0000;"> -41.44</span></td>
</tr>
<tr>
<td id="N_Name">Netsuite Inc</td>
<td id="N_Symbol"><a href="http://finance.google.com/finance?q=N&amp;hl=en" target="_blank">N</a></td>
<td id="N_Price" style="TEXT-ALIGN: right">20.3</td>
<td id="N_MarketCap" style="text-align: right;"> 7</td>
<td id="N_PE" style="text-align: right;"> <span style="color: #ff0000;">-65.52</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="OMTR_Name">Omniture, Inc.</td>
<td id="OMTR_Symbol"><a href="http://finance.google.com/finance?q=OMTR&amp;hl=en" target="_blank">OMTR</a></td>
<td id="OMTR_Price" style="TEXT-ALIGN: right">19.9</td>
<td id="OMTR_MarketCap" style="text-align: right;"> 9.09</td>
<td id="OMTR_PE" style="text-align: right;"><span style="color: #ff0000;"> -54.32</span></td>
</tr>
<tr>
<td id="RNOW_Name">RightNow Technologies</td>
<td id="RNOW_Symbol"><a href="http://finance.google.com/finance?q=RNOW&amp;hl=en" target="_blank">RNOW</a></td>
<td id="RNOW_Price" style="TEXT-ALIGN: right">13.7</td>
<td id="RNOW_MarketCap" style="text-align: right;"> 5.84</td>
<td id="RNOW_PE" style="text-align: right;"><span style="color: #ff0000;"> -57.37</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="SFSF_Name">SuccessFactors, Inc.</td>
<td id="SFSF_Symbol"><a href="http://finance.google.com/finance?q=SFSF&amp;hl=en" target="_blank">SFSF</a></td>
<td id="SFSF_Price" style="text-align: right;"> 11</td>
<td id="SFSF_MarketCap" style="text-align: right;"> 6.73</td>
<td id="SFSF_PE" style="text-align: right;"><span style="color: #ff0000;"> -38.82</span></td>
</tr>
<tr>
<td id="SLRY_Name">Salary.com, Inc.</td>
<td id="SLRY_Symbol"><a href="http://finance.google.com/finance?q=SLRY&amp;hl=en" target="_blank">SLRY</a></td>
<td id="SLRY_Price" style="text-align: right;"> 4</td>
<td id="SLRY_MarketCap" style="text-align: right;"> 1.77</td>
<td id="SLRY_PE" style="text-align: right;"><span style="color: #ff0000;"> -55.75</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="TLEO_Name">Taleo Corporation</td>
<td id="TLEO_Symbol"><a href="http://finance.google.com/finance?q=TLEO&amp;hl=en" target="_blank">TLEO</a></td>
<td id="TLEO_Price" style="text-align: right;"> 19.6</td>
<td id="TLEO_MarketCap" style="text-align: right;"> 8.43</td>
<td id="TLEO_PE" style="text-align: right;"><span style="color: #ff0000;"> -56.99</span></td>
</tr>
<tr>
<td id="TRAK_Name">DealerTrack Holdings, Inc.</td>
<td id="TRAK_Symbol"><a href="http://finance.google.com/finance?q=TRAK&amp;hl=en" target="_blank">TRAK</a></td>
<td id="TRAK_Price" style="text-align: right;"> 15.5</td>
<td id="TRAK_MarketCap" style="text-align: right;"> 11.39</td>
<td id="TRAK_PE" style="text-align: right;"><span style="color: #ff0000;"> -26.52</span></td>
</tr>
<tr>
<td id="ULTI_Name">The Ultimate Software Group</td>
<td id="ULTI_Symbol"><a href="http://finance.google.com/finance?q=ULTI&amp;hl=en" target="_blank">ULTI</a></td>
<td id="ULTI_Price" style="text-align: right;"> 36.7</td>
<td id="ULTI_MarketCap" style="text-align: right;"> 13.77</td>
<td id="ULTI_PE" style="text-align: right;"><span style="color: #ff0000;"> -62.48</span></td>
</tr>
<tr style="background-color:#E6E6E6; ">
<td id="VOCS_Name">Vocus, Inc.</td>
<td id="VOCS_Symbol"><a href="http://finance.google.com/finance?q=VOCS&amp;hl=en" target="_blank">VOCS</a></td>
<td id="VOCS_Price" style="text-align: right;"> 32.4</td>
<td id="VOCS_MarketCap" style="text-align: right;"> 15.26</td>
<td id="VOCS_PE" style="text-align: right;"><span style="color: #ff0000;"> -52.90</span></td>
</tr>
<tr style="background-color:#FFCC33; font-weight:bold; ">
<td id="TOTAL_Name">TOTAL</td>
<td id="TOTAL_Symbol"> </td>
<td id="TOTAL_RunningJan" align="right"> </td>
<td id="TOTAL_RunningYear" align="right"> </td>
<td id="TOTAL_PE" style="text-align: right;"><span style="color: #ff0000;"> -42.44</span></td>
</tr>
</tbody>
</table>
<p>
Ok, ok, you can blame the economy.  But maybe the market still hasn&#8217;t warmed up to the idea of SaaS as much as this blog has. Or, just as the <a href="http://www.warriorpoint.com/blog/2008/07/02/whether-you-invest-in-saas-stocks-or-not-dont-forget-the-fundamentals/" target="_blank">original article </a>claims, these are companies just like any other and they are suffering the same ups and downs as all other companies - the industry they are in is just a small portion of the overall formula.</p>
<p>For example, salesforce was hugely overvalued at $60 (personal opinion), while athenahealth keeps signing more contracts <a href="http://www.businesswire.com/portal/site/google/?ndmViewId=news_view&amp;newsId=20090122005106&amp;newsLang=en" target="_blank">[1]</a> <a href="http://www.businesswire.com/portal/site/google/?ndmViewId=news_view&amp;newsId=20090127005109&amp;newsLang=en" target="_blank">[2]</a>.</p>
<p>I really want to say: look, all companies but one have posted decreases, this means SaaS is still new and not being adopted. However, I know in my heart that so many companies in the red must have some kind of influence from the sagging economy. It would be quite the coincidence if they are all red because of their industry.</p>
<p>That&#8217;s all for now. I will check back on these stocks soon. Maybe when the economoy is stabalized in 2 years, looking at these figures will make more sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.warriorpoint.com/blog/2009/01/31/checking-up-on-the-on-demand-index/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
