How To Get Resource Id Dynamically In Android
Posted by admin on
July 11, 2012
In Android, we normally use the R class in order to gain access to the drawable, layout, string (and others) variables.
I made this helper method to get a resource id dynamically. However, if you have no need for this, it is a better option to use the R class directly as the search operation is quicker compared to this.
public static int getResId(String variableName, Context context, Class<?> c) { try { Field idField = c.getDeclaredField(variableName); return idField.getInt(idField); } catch (Exception e) { e.printStackTrace(); return -1; } }
Let us say, you have an XML file named help.xml in your res/layout/ folder. To use the method, do it like this.
getRestId("help", this, R.layout.class);
tags: drawable, dynamic, getdeclaredfield, id, layout, resource, string
No Comments
How To Fix ResourceDictionary Is Inside A ResourceDictionary And Does Not Have A Key
Posted by admin on
February 24, 2012
The solution is very easy actually but usually hounds new Windows Phone developers when they start with XAML. Just make sure your ResourceDictionary tag is first in your Application.Resources tag.
I encountered this problem because I declared the internationalization resource file first and then resource dictionary second (see code below).
<Application.Resources> <local:LocalizedStrings xmlns:local="clr-namespace:HelloWorld.Resources" x:Key="LocalizedStrings" /> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
By transferring the ResourceDictionary tag to the top, that fixed the problem.
Donations appreciated. Every little $ helps. Or click Google +1. Or play the short video on the upper right of this page.Gambling.org
Posted by admin on
September 6, 2010
Bonus wagering requirements at online casinos can be a bit tricky. Scams are everywhere so it pays to be careful and knowledgeable. Even information related sites can become scams so you at least have to have an idea which sites are considered legit and which are not.
If there is one of them that is legit, it is Gambling.org. You can find the best online gambling sites with reviews and information on what they offer to gamers. If you are a newbie, no problem. The site features articles just for them to help get them started in the world of online casino.
You won’t have a hard time navigating around the site. It is powered by the most powerful content management system, WordPress so browsing through the articles and looking for the information that you need is easy. What you need to do, is just to take advantage of the plethora of resources and articles provided for anybody who is into online gaming.
Whether you are a newbie or a professional gamer, gambling.org is a good place to start searching for anything online casino related. The various reviews, tips, strategies and news will keep online gamers up to date with anything related to casino.
Donations appreciated. Every little $ helps. Or click Google +1. Or play the short video on the upper right of this page.







