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

<channel>
	<title>ERiDeM&#039;s Blog</title>
	<atom:link href="http://www.eridem.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eridem.net</link>
	<description>Quick code tips and hobbies</description>
	<lastBuildDate>Sat, 05 Nov 2011 12:36:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Google I/O 2011 Android videos</title>
		<link>http://www.eridem.net/google-io-2011-android-videos</link>
		<comments>http://www.eridem.net/google-io-2011-android-videos#comments</comments>
		<pubDate>Sat, 04 Jun 2011 11:21:24 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1474</guid>
		<description><![CDATA[All the lectures related with Android in the Google I/O 2011. Click on the titles to redirect to the video website. Android Development Tools Android Protips: Advanced Topics for Expert Android App Developers Memory management for Android Apps Designing and Implementing Android UIs for Phones and Tablets Honeycomb Highlights &#160; Accelerated Android Rendering 3D Graphics [...]]]></description>
			<content:encoded><![CDATA[<p>All the lectures related with Android in the Google I/O 2011. Click on the titles to redirect to the video website.</p>
<ul>
<li><a href="http://www.google.com/events/io/2011/sessions/android-development-tools.html">Android Development Tools</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/android-protips-advanced-topics-for-expert-android-app-developers.html">Android Protips: Advanced Topics for Expert Android App Developers</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/memory-management-for-android-apps.html">Memory management for Android Apps</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/designing-and-implementing-android-uis-for-phones-and-tablets.html">Designing and Implementing Android UIs for Phones and Tablets</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/honeycomb-highlights.html">Honeycomb Highlights<br /></a></li>
</ul>
<p>&nbsp;
<ul>
<li><a href="http://www.google.com/events/io/2011/sessions/accelerated-android-rendering.html">Accelerated Android Rendering</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/3d-graphics-on-android-lessons-learned-from-google-body.html">3D Graphics on Android: Lessons learned from Google Body</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/bringing-c-and-c-games-to-android.html">Bringing C and C++ Games to Android</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/building-aggressively-compatible-android-games.html">Building Aggressively Compatible Android Games</a></li>
</ul>
<p>&nbsp;
<ul>
<li><a href="http://www.google.com/events/io/2011/sessions/best-practices-for-accessing-google-apis-on-android.html">Best Practices for Accessing Google APIs on Android</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/leveraging-android-accessibility-apis-to-create-an-accessible-experience.html">Leveraging Android Accessibility APIs To Create An Accessible Experience</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/android-open-accessory-api-and-development-kit-adk.html">Android Open Accessory API and Development Kit (ADK)</a></li>
</ul>
<p>&nbsp;
<ul>
<li><a href="http://www.google.com/events/io/2011/sessions/android-app-engine-a-developer-s-dream-combination.html">Android + App Engine: A Developer&#8217;s Dream Combination</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/how-to-nfc.html">How to NFC</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/building-android-apps-for-google-tv.html">Building Android Apps for Google TV</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/optimizing-android-apps-with-google-analytics.html">Optimizing Android Apps with Google Analytics</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/html5-versus-android-apps-or-web-for-mobile-development.html">HTML5 versus Android: Apps or Web for Mobile Development?</a></li>
</ul>
<p>&nbsp;
<ul>
<li><a href="http://www.google.com/events/io/2011/sessions/evading-pirates-and-stopping-vampires-using-license-verification-library-in-app-billing-and-app-engine.html">Evading Pirates and Stopping Vampires using License Verification Library, In-App Billing, and App Engine</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/dont-just-build-a-mobile-app-build-a-business.html">Don&rsquo;t just build a mobile app. Build a business.</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/taking-android-to-work.html">Taking Android to Work</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/android-market-for-developers.html">Android Market for Developers</a></li>
<li><a href="http://www.google.com/events/io/2011/sessions/fireside-chat-with-the-android-team.html">Fireside Chat with the Android Team</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/google-io-2011-android-videos/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android tip #028 &#8211; Sync two ScrollLayouts when scroll</title>
		<link>http://www.eridem.net/android-tip-028-sync-two-scrolllayouts-when-scroll</link>
		<comments>http://www.eridem.net/android-tip-028-sync-two-scrolllayouts-when-scroll#comments</comments>
		<pubDate>Sat, 04 Jun 2011 10:45:36 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android Tips]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1464</guid>
		<description><![CDATA[Platform/Language: Java/XML/Android Description: if we need to scroll two ScrollLayouts at the same time we can create a new View that implements the standard ScrollView in order to create a listener which allow us to know when this one is scrolling and modify the behavior of the other (or maybe because we want to know [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Platform/Language</strong>: Java/XML/Android</p>
<p><strong>Description</strong>: if we need to scroll two ScrollLayouts at the same time we can create a new View that implements the standard ScrollView in order to create a listener which allow us to know when this one is scrolling and modify the behavior of the other (or maybe because we want to know about the scroll behavior).</p>
<p><strong>Code</strong>:</p>
<p align="center"><i>IScrollListener.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> IScrollListener <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; <span style="color: #000066; font-weight: bold;">void</span> onScrollChanged<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; IScrollListener scrollView, <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y, <span style="color: #000066; font-weight: bold;">int</span> oldx, <span style="color: #000066; font-weight: bold;">int</span> oldy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</p>
<p align="center"><i>ObservableScrollView.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ObservableScrollView <span style="color: #000000; font-weight: bold;">extends</span> ScrollView <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> IScrollListener listener <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> ObservableScrollView<span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span> context<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> ObservableScrollView<span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span> context, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003399;">AttributeSet</span> attrs, <span style="color: #000066; font-weight: bold;">int</span> defStyle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context, attrs, defStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> ObservableScrollView<span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span> context,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003399;">AttributeSet</span> attrs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>context, attrs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setScrollViewListener<span style="color: #009900;">&#40;</span>IScrollListener listener<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">listener</span> <span style="color: #339933;">=</span> listener<span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; @Override<br />
&nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onScrollChanged<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">int</span> oldx, <span style="color: #000066; font-weight: bold;">int</span> oldy<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onScrollChanged</span><span style="color: #009900;">&#40;</span>x, y, oldx, oldy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>listener <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listener.<span style="color: #006633;">onScrollChanged</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, x, y, oldx, oldy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</p>
<p>Use two <i>ObservableScrollView</i> in your layout: oScrollViewOne, oScrollViewTwo.</p>
<p align="center"><i>YoutActivity.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> YourActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">implements</span> ScrollViewListener <span style="color: #009900;">&#123;</span><br />
&nbsp; ObservableScrollView oScrollViewOne, oScrollViewTwo<span style="color: #339933;">;</span><br />
<br />
&nbsp; @Override<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; oScrollViewOne <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ObservableScrollView<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">oScrollViewOne</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; oScrollViewTwo <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ObservableScrollView<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">oScrollViewTwo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; oScrollViewOne.<span style="color: #006633;">setScrollViewListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; oScrollViewTwo.<span style="color: #006633;">setScrollViewListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; @Override<br />
&nbsp; <span style="color: #000066; font-weight: bold;">void</span> onScrollChanged<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; IScrollListener scrollView, <br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y, <span style="color: #000066; font-weight: bold;">int</span> oldx, <span style="color: #000066; font-weight: bold;">int</span> oldy<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scrollView <span style="color: #339933;">==</span> oScrollViewOne<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; oScrollViewTwo.<span style="color: #006633;">scrollTo</span><span style="color: #009900;">&#40;</span>x, y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>scrollView <span style="color: #339933;">==</span> oScrollViewTwo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; oScrollViewOne.<span style="color: #006633;">scrollTo</span><span style="color: #009900;">&#40;</span>x, y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/android-tip-028-sync-two-scrolllayouts-when-scroll/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android tip #027 &#8211; Add shadow to labels, buttons and other views</title>
		<link>http://www.eridem.net/android-tip-027-add-shadow-to-lables-buttons-and-other-view</link>
		<comments>http://www.eridem.net/android-tip-027-add-shadow-to-lables-buttons-and-other-view#comments</comments>
		<pubDate>Fri, 03 Jun 2011 19:02:06 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android Tips]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1456</guid>
		<description><![CDATA[Platform/Language: Java/XML/Android Description: We can drop shadows to our controls (TextView, Buttons, Checkbox, &#8230;). Adding this shadow, we can create a better interface in our applications (but be careful adding shadow to everything!). Result Code: my_layout.xml 1234567891011121314&#60;!-- ... --&#62; &#60;TextView &#160; android:layout_width=&#34;wrap_content&#34; &#160; android:layout_height=&#34;wrap_content&#34; &#160; &#160; android:textColor=&#34;@android:color/black&#34; &#160; android:text=&#34;@string/eridemNet&#34; &#160; &#160; android:shadowRadius=&#34;3&#34; &#160; android:shadowDx=&#34;3&#34; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Platform/Language</strong>: Java/XML/Android</p>
<p><strong>Description</strong>: We can drop shadows to our controls (TextView, Buttons, Checkbox, &#8230;). Adding this shadow, we can create a better interface in our applications (but be careful adding shadow to everything!).</p>
<p><strong>Result</strong></p>
<p align="center"><img src="http://www.eridem.net/blog/wp-content/uploads/shadow_text.png" alt="" title="shadow_text" width="470" height="65" class="aligncenter size-full wp-image-1457" /></p>
<p><strong>Code</strong>:</p>
<p align="center"><i>my_layout.xml</i></p>
<div class="codecolorer-container xml blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">&lt;!-- ... --&gt;</span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; </span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:textColor</span>=<span style="color: #ff0000;">&quot;@android:color/black&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/eridemNet&quot;</span></span><br />
<span style="color: #009900;">&nbsp; </span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowRadius</span>=<span style="color: #ff0000;">&quot;3&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowDx</span>=<span style="color: #ff0000;">&quot;3&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowDy</span>=<span style="color: #ff0000;">&quot;2&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowColor</span>=<span style="color: #ff0000;">&quot;@android:color/black&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/TextView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #808080; font-style: italic;">&lt;!-- ... --&gt;</span></div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/android-tip-027-add-shadow-to-lables-buttons-and-other-view/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android tip #026 &#8211; Create nice buttons with XML</title>
		<link>http://www.eridem.net/android-tip-026-create-nice-buttons-with-xml</link>
		<comments>http://www.eridem.net/android-tip-026-create-nice-buttons-with-xml#comments</comments>
		<pubDate>Fri, 03 Jun 2011 18:46:21 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android Tips]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1448</guid>
		<description><![CDATA[Platform/Language: XML/Android Description: We can create nice buttons simply using few colors and gradients. We need to create a Selector resource and attach all the shape items for every state: pressed, focussed, disabled and normal. In the most common cases, focussed and normal could show the same result. In the case of pressed and normal, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Platform/Language</strong>: XML/Android</p>
<p><strong>Description</strong>: We can create nice buttons simply using few colors and gradients. We need to create a Selector resource and attach all the shape items for every state: pressed, focussed, disabled and normal. In the most common cases, focussed and normal could show the same result. In the case of pressed and normal, we will invert the colors. And in the case of disabled, we will use other colors (like a gray color).</p>
<p><strong>Result</strong></p>
<p align="center"><img src="http://www.eridem.net/blog/wp-content/uploads/custom_button.png" alt="Custom nice button" title="Custom nice button" width="472" height="67" class="alignnone size-full wp-image-1450" /></p>
<p><strong>Code</strong>:</p>
<p align="center"><i>colors.xml</i> in /values/</p>
<div class="codecolorer-container xml blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NiceButtonStartColor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>#4AA02C<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NiceButtonEndColor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>#348017<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NiceButtonDisabledStartColor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>#565051<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NiceButtonDisabledEndColor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>#736F6E<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;color</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;NiceButtonBorderColor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>#254117<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/color<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
</p>
<p align="center"><i>nice_button.xml</i> in /drawables/</p>
<div class="codecolorer-container xml blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;selector</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:state_pressed</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gradient</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:endColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonStartColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:startColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonEndColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:angle</span>=<span style="color: #ff0000;">&quot;270&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stroke</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:width</span>=<span style="color: #ff0000;">&quot;1dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:color</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonBorderColor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;corners</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:radius</span>=<span style="color: #ff0000;">&quot;3dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;padding</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:left</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:top</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:right</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:bottom</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:state_focused</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gradient</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:startColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonStartColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:endColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonEndColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:angle</span>=<span style="color: #ff0000;">&quot;270&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stroke</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:width</span>=<span style="color: #ff0000;">&quot;1dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:color</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonBorderColor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;corners</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:radius</span>=<span style="color: #ff0000;">&quot;3dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;padding</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:left</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:top</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:right</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:bottom</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:state_enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gradient</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:startColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonDisabledStartColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:endColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonDisabledEndColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:angle</span>=<span style="color: #ff0000;">&quot;270&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stroke</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:width</span>=<span style="color: #ff0000;">&quot;1dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:color</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonBorderColor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;corners</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:radius</span>=<span style="color: #ff0000;">&quot;3dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;padding</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:left</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:top</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:right</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:bottom</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;gradient</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:startColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonStartColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:endColor</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonEndColor&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:angle</span>=<span style="color: #ff0000;">&quot;270&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stroke</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:width</span>=<span style="color: #ff0000;">&quot;1dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:color</span>=<span style="color: #ff0000;">&quot;@color/NiceButtonBorderColor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;corners</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:radius</span>=<span style="color: #ff0000;">&quot;3dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;padding</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:left</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:top</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:right</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:bottom</span>=<span style="color: #ff0000;">&quot;10dp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/shape<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/selector<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
</p>
<p align="center"><i>my_layout.xml</i></p>
<div class="codecolorer-container xml blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">&lt;!-- ... --&gt;</span><br />
<span style="color: #808080; font-style: italic;">&lt;!-- Better if you use most of the attributes in a style --&gt;</span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Button</span> </span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/btnStart&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span>&nbsp; </span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;40dp&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:layout_margin</span>=<span style="color: #ff0000;">&quot;3dp&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:gravity</span>=<span style="color: #ff0000;">&quot;center&quot;</span></span><br />
<br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:background</span>=<span style="color: #ff0000;">&quot;@drawable/nice_button&quot;</span></span><br />
<br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/labelStart&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:textColor</span>=<span style="color: #ff0000;">&quot;@android:color/white&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:textSize</span>=<span style="color: #ff0000;">&quot;18sp&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowRadius</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowDx</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowDy</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; <span style="color: #000066;">android:shadowColor</span>=<span style="color: #ff0000;">&quot;@android:color/black&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/Button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #808080; font-style: italic;">&lt;!-- ... --&gt;</span></div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/android-tip-026-create-nice-buttons-with-xml/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ERiDeM Monsters</title>
		<link>http://www.eridem.net/eridem-monsters</link>
		<comments>http://www.eridem.net/eridem-monsters#comments</comments>
		<pubDate>Mon, 25 Apr 2011 08:25:35 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Projects/Libraries/APIs]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1410</guid>
		<description><![CDATA[A year ago, I started programming with XNA and I decided to build some game examples. One idea was create a clone of the videogame PixelJunk Monster but with some differences: the stages, chips, characters, monsters, paths and behavior could be totally customizable. For that propose, I did a Stage Tool application too. The project [...]]]></description>
			<content:encoded><![CDATA[<p>A year ago, I started programming with XNA and I decided to build some game examples. One idea was create a clone of the videogame <a href="http://pixeljunk.jp/">PixelJunk Monster</a> but with some differences: the stages, chips, characters, monsters, paths and behavior could be totally customizable. For that propose, I did a Stage Tool application too.
<p>The project is not released because it needs music, effect, better graphics (and maybe fix bugs too), and so on. But here, some captures and the main screen song.</p>
<p align="center"><a href="http://www.jamendo.com/album/55062">RedQuadro &#8211; Morning Wave</a><br />
<audio src="http://www.eridem.net/blog/wp-content/uploads/RedQuadro-Morning-Wave.mp3" controls><br />
 <object type="application/x-shockwave-flash" data="player_mp3.swf" width="200" height="20"><param name="movie" value="player_mp3.swf" /><param name="FlashVars" value="mp3=music.mp3&#038;showstop=1&#038;showinfo=1" /></object><br />
</audio>
</p>
<p></p>
<p align="center">
<a href="http://www.eridem.net/blog/wp-content/uploads/monsters_title.jpg"><img src="http://www.eridem.net/blog/wp-content/uploads/monsters_title-300x169.jpg" alt="" title="monsters_title" width="300" height="169" class="alignnone size-medium wp-image-1411" /></a><br />
<a href="http://www.eridem.net/blog/wp-content/uploads/monsters_stage01.jpg"><img src="http://www.eridem.net/blog/wp-content/uploads/monsters_stage01-300x168.jpg" alt="" title="monsters_stage01" width="300" height="168" class="alignnone size-medium wp-image-1413" /></a><br />
<a href="http://www.eridem.net/blog/wp-content/uploads/monsters_stage02.jpg"><img src="http://www.eridem.net/blog/wp-content/uploads/monsters_stage02-300x193.jpg" alt="" title="monsters_stage02" width="300" height="193" class="alignnone size-medium wp-image-1412" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/eridem-monsters/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.eridem.net/blog/wp-content/uploads/RedQuadro-Morning-Wave.mp3" length="6497293" type="audio/mpeg" />
<enclosure url="http://www.eridem.net/blog/wp-content/uploads/RedQuadro-Morning-Wave.mp3" length="6497293" type="audio/mpeg" />
		</item>
		<item>
		<title>Cleaning unused Android resources</title>
		<link>http://www.eridem.net/cleaning-unused-android-resources</link>
		<comments>http://www.eridem.net/cleaning-unused-android-resources#comments</comments>
		<pubDate>Sun, 24 Apr 2011 10:58:49 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1405</guid>
		<description><![CDATA[On middle/big projects we usually add lots of resources that we can use on code files, layouts or other resources. When we start to do modifications to the project, sometimes we forgot to remove unused strings, drawables, layouts and so on. I wanted to create a script to check these unused resources on our Android [...]]]></description>
			<content:encoded><![CDATA[<p>On middle/big projects we usually add lots of resources that we can use on code files, layouts or other resources. When we start to do modifications to the project, sometimes we forgot to remove unused strings, drawables, layouts and so on.
<p>I wanted to create a script to check these unused resources on our Android project, but I found a project which already does this task. This project is called <em>android-unused-resources</em> (good name to google it), and we can download it from:
<p align="center"><a href="http://code.google.com/p/android-unused-resources/">http://code.google.com/p/android-unused-resources/</a></p>
<p>The use is simple, add the file to the root project and execute it:</p>
<div class="codecolorer-container bash blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">java <span style="color: #660033;">-jar</span> AndroidUnusedResources.jar</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/cleaning-unused-android-resources/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check missing strings for a multi-language Android application</title>
		<link>http://www.eridem.net/check-missing-strings-for-a-multi-language-android-app</link>
		<comments>http://www.eridem.net/check-missing-strings-for-a-multi-language-android-app#comments</comments>
		<pubDate>Wed, 20 Apr 2011 07:08:22 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1395</guid>
		<description><![CDATA[When we are creating a multi-language application for Android, we need to create several folders to save the strings of different languages (see Android tip #014 &#8211; Multi-language application). When we are handling hundred or thousand of strings, we can forget adding a string in all language files. Looking for a tool to organize all [...]]]></description>
			<content:encoded><![CDATA[<p>When we are creating a multi-language application for Android, we need to create several folders to save the strings of different languages (see <em><a href="http://www.eridem.net/android-tip-014-multi-language-application">Android tip #014 &#8211; Multi-language application</a></em>). When we are handling hundred or thousand of strings, we can <em>forget</em> adding a string in all language files.</p>
<p>Looking for a tool to organize all the strings in my project and check if any string was missing, I found the <a href="http://wfmh.org.pl/carlos/blog/">W.F.M.H&#8217;s blog</a> were you can download a PHP script to help you for checking all your strings.</p>
<p>The usage is easy (using ES language as example)</p>
<div class="codecolorer-container bash blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>string-check.php values<span style="color: #000000; font-weight: bold;">/</span>strings.xml values-es<span style="color: #000000; font-weight: bold;">/</span>strings.xml</div></div>
<p>You could get a result similar to:</p>
<div class="codecolorer-container bash blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Missing <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">&lt;</span>LANG<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>You need to add these to your <span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
File: values-es<span style="color: #000000; font-weight: bold;">/</span>strings.xml<br />
<span style="color: #660033;">------------------------------------------------------</span><br />
header_title<br />
description_label<br />
<br />
Missing <span style="color: #000000; font-weight: bold;">in</span> EN <span style="color: #7a0874; font-weight: bold;">&#40;</span>you probably shall remove it from your <span style="color: #000000; font-weight: bold;">&lt;</span>LANG<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
File: values<span style="color: #000000; font-weight: bold;">/</span>strings.xml<br />
<span style="color: #660033;">------------------------------------------------------------------</span><br />
mysection_label<br />
<br />
Summary<br />
<span style="color: #660033;">----------------</span><br />
BASE file: <span style="color: #ff0000;">'values/strings.xml'</span><br />
LANG file: <span style="color: #ff0000;">'values-de/strings.xml'</span><br />
&nbsp; &nbsp;<span style="color: #000000;">2</span> missing <span style="color: #c20cb9; font-weight: bold;">strings</span> <span style="color: #000000; font-weight: bold;">in</span> your LANG file.<br />
&nbsp; &nbsp;<span style="color: #000000;">1</span> obsolete <span style="color: #c20cb9; font-weight: bold;">strings</span> <span style="color: #000000; font-weight: bold;">in</span> your LANG file.</div></div>
<p>For more information about the project, visit the main website (recommended): <br /><strong><a href="http://wfmh.org.pl/carlos/blog/2010/07/06/android-translators-helper-tool/">W.F.M.H.&#8217;s blog, Android translators&#8217; helper tool</a></strong></p>
<p>Or download the script directly from his/her website: <strong><a href="http://wfmh.org.pl/carlos/blog/wp-content/strings-check.zip">strings-check.zip</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/check-missing-strings-for-a-multi-language-android-app/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android tip #025 &#8211; Launch Activity from a service</title>
		<link>http://www.eridem.net/android-tip-025-launch-activity-from-a-service</link>
		<comments>http://www.eridem.net/android-tip-025-launch-activity-from-a-service#comments</comments>
		<pubDate>Mon, 18 Apr 2011 13:52:39 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android Tips]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1391</guid>
		<description><![CDATA[Platform/Language: Java/Android Description: if we have a service in background and we need to launch an Activity in foreground, we need to add the tag FLAG_ACTIVITY_NEW_TASK to the Intent. Code: MyService.java 1234567891011public class MyService extends Service &#123; &#160; /* ... */ &#160; private void launchActivity&#40;&#41; &#123; &#160; &#160; Intent intent = new Intent&#40;this, MyActivity.class&#41;; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Platform/Language</strong>: Java/Android</p>
<p><strong>Description</strong>: if we have a service in background and we need to launch an Activity in foreground, we need to add the tag <em>FLAG_ACTIVITY_NEW_TASK</em> to the Intent.</p>
<p><strong>Code</strong>:</p>
<p align="center"><i>MyService.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyService <span style="color: #000000; font-weight: bold;">extends</span> Service <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">/* ... */</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> launchActivity<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; Intent intent <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, MyActivity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; intent.<span style="color: #006633;">addFlags</span><span style="color: #009900;">&#40;</span>Intent.<span style="color: #006633;">FLAG_ACTIVITY_NEW_TASK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">startActivity</span><span style="color: #009900;">&#40;</span>intent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">/* ... */</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/android-tip-025-launch-activity-from-a-service/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android tip #024 &#8211; Optimize lists a 175%</title>
		<link>http://www.eridem.net/android-tip-024-optimize-lists-a-175</link>
		<comments>http://www.eridem.net/android-tip-024-optimize-lists-a-175#comments</comments>
		<pubDate>Sat, 09 Apr 2011 14:15:53 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android Tips]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1379</guid>
		<description><![CDATA[Platform/Language: Java/XML/Android Related with: Optimize lists a 150% Description: two operations are expensive when we create custom lists: Inflate (covered on the tip 23) and findByViewId(int). We can avoid call to this second operation saving the views used for every row in a wrapper. This pattern implies use a Model and a Wrapper. The Model [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Platform/Language</strong>: Java/XML/Android</p>
<p><strong>Related with:</strong> <a href="/android-tip-023-optimize-lists-a-150">Optimize lists a 150%</a></p>
<p><strong>Description</strong>: two operations are <em>expensive</em> when we create custom lists: Inflate (covered on the <a href="/android-tip-023-optimize-lists-a-150">tip 23</a>) and <em>findByViewId(int)</em>. We can avoid call to this second operation saving the views used for every row in a wrapper.</p>
<p>This pattern implies use a Model and a Wrapper. The Model will save the information of every row and the Wrapper will save the Views. We need to save the wrapper in every row view using the properties <em>getTag()</em> and <em>setTag(Object)</em>.</p>
<p>This example will use only one value in the model and a TextView in the wrapper, but you can extend it as much as you wish.</p>
<p><strong>Code</strong>:</p>
<p align="center">Model: <i>Item.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Item <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> value <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">value</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">value</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">value</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setValue<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">value</span> <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</p>
<p align="center">Wrapper: <i>ItemWrapper.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ItemWrapper <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">View</span> row <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> TextView mTextView <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> ItemWrapper<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> row<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mRow</span> <span style="color: #339933;">=</span> row<span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">private</span> TextView getMTextView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mTextView</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mTextView</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">row</span>.<span style="color: #006633;">findViewById</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">your_row_layout_textview</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mTextView</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> populate<span style="color: #009900;">&#40;</span>Item item<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getMTextView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>item.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</p>
<p align="center">Adapter: <i>MyAdapter.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Item<span style="color: #339933;">&gt;</span> items<span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">/* ... */</span><br />
<br />
@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">View</span> getView<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> position, <span style="color: #003399;">View</span> convertView,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ViewGroup parent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #003399;">View</span> row <span style="color: #339933;">=</span> convertView<span style="color: #339933;">;</span><br />
&nbsp; ItemWrapper wrapper <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>row <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; LayoutInflater inflater <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LayoutInflater<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mContext</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">getSystemService</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">LAYOUT_INFLATER_SERVICE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; row <span style="color: #339933;">=</span> inflater.<span style="color: #006633;">inflate</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">your_row_layout</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; wrapper <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ItemWrapper<span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; row.<span style="color: #006633;">setTag</span><span style="color: #009900;">&#40;</span>wrapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <br />
&nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; wrapper <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ItemWrapper<span style="color: #009900;">&#41;</span> row.<span style="color: #006633;">getTag</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">/* Populate row */</span><br />
&nbsp; wrapper.<span style="color: #006633;">populate</span><span style="color: #009900;">&#40;</span>items.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; <br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">return</span> row<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/android-tip-024-optimize-lists-a-175/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android tip #023 &#8211; Optimize lists a 150%</title>
		<link>http://www.eridem.net/android-tip-023-optimize-lists-a-150</link>
		<comments>http://www.eridem.net/android-tip-023-optimize-lists-a-150#comments</comments>
		<pubDate>Sat, 09 Apr 2011 13:49:21 +0000</pubDate>
		<dc:creator>ERiDeM</dc:creator>
				<category><![CDATA[Android Tips]]></category>

		<guid isPermaLink="false">http://www.eridem.net/?p=1373</guid>
		<description><![CDATA[Platform/Language: Java/XML/Android Related with: Optimize lists a 175% Description: we can optimize the Adapters attached to a ListView inflating our custom layouts when it is necessary. This process is easy to implement with only one condition (Android will managed the rest of the work). MyAdapter.java 12345678910111213141516171819/* ... */ @Override public View getView&#40;int position, View convertView, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Platform/Language</strong>: Java/XML/Android</p>
<p><strong>Related with:</strong> <a href="/android-tip-024-optimize-lists-a-175">Optimize lists a 175%</a></p>
<p><strong>Description</strong>: we can optimize the Adapters attached to a ListView inflating our custom layouts when it is necessary. This process is easy to implement with only one condition (Android will managed the rest of the work).</p>
<p align="center"><i>MyAdapter.java</i></p>
<div class="codecolorer-container java blackboard notranslate" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/* ... */</span><br />
<br />
@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">View</span> getView<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> position, <span style="color: #003399;">View</span> convertView,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ViewGroup parent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #003399;">View</span> row <span style="color: #339933;">=</span> convertView<span style="color: #339933;">;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>row <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; LayoutInflater inflater <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LayoutInflater<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mContext</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">getSystemService</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">LAYOUT_INFLATER_SERVICE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; row <span style="color: #339933;">=</span> inflater.<span style="color: #006633;">inflate</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">your_row_layout</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #666666; font-style: italic;">/* Populate row */</span><br />
&nbsp; <br />
&nbsp; <span style="color: #000000; font-weight: bold;">return</span> row<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">/* ... */</span></div></td></tr></tbody></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eridem.net/android-tip-023-optimize-lists-a-150/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

