<?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>dev. &#187; android</title>
	<atom:link href="http://coliena.com/blog/tag/android/feed/" rel="self" type="application/rss+xml" />
	<link>http://coliena.com/blog</link>
	<description>some software engineers&#039; random rants and thoughts</description>
	<lastBuildDate>Mon, 30 Aug 2010 20:02:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Android: Get String From Resource By Name</title>
		<link>http://coliena.com/blog/2009/11/android-get-string-from-resource-by-name/</link>
		<comments>http://coliena.com/blog/2009/11/android-get-string-from-resource-by-name/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 16:54:58 +0000</pubDate>
		<dc:creator>niels</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://coliena.com/blog/?p=227</guid>
		<description><![CDATA[Usually the string resources in your Android application are being referred to by a unique ID. But sometimes you will want to recover a string by its key, e. g. when you build the key of the string at the run time of your application (&#8220;Battery_Health_2&#8243; or &#8220;Battery_Health_3&#8243;). You can do that like this: private [...]]]></description>
			<content:encoded><![CDATA[<p>Usually the string resources in your Android application are being referred to by a unique ID. But sometimes you will want to recover a string by its key, e. g. when you build the key of the string at the run time of your application (&#8220;Battery_Health_2&#8243; or &#8220;Battery_Health_3&#8243;). You can do that like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> getStringResourceByName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aString<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">String</span> packageName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;com.coliena.myapp&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">int</span> resId <span style="color: #339933;">=</span> getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getIdentifier</span><span style="color: #009900;">&#40;</span>aString, <span style="color: #0000ff;">&quot;string&quot;</span>, packageName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">return</span> getString<span style="color: #009900;">&#40;</span>resId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Check <a href="http://www.anddev.org/viewtopic.php?p=24260">this link</a> if you need to recover in image resource by its name.<br />
More information about string resources is available in the <a href="http://developer.android.com/guide/topics/resources/available-resources.html#stringresources">Android Developer Documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://coliena.com/blog/2009/11/android-get-string-from-resource-by-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
