On 14 September 2010 17:24, nextgen <[email protected]> wrote:
> Thank you for this, it gives me a possible solution. Unfortunately
> getDrawable will only take an integer as an input, which really
> defeats the simplicity of solution I'm looking for. I can set about
> assigning integers to each team, but I'm not sure that would even do
> it because I'm not sure about the nature of the integer it wants.
> Here is the description I see in Eclipse:
// returns ID of drawable given by name (i.e. getDrawableByName(
"app_icon" );
public static int getDrawableByName( String name )
{
int drawableId = 0;
try {
Class res = R.drawable.class;
Field field = res.getField( name );
drawableId = field.getInt(null);
}
catch (Exception e) {
// Toast.makeText(context, "DIT Service: onStartCommand()",
Toast.LENGTH_SHORT).show();
Log.e("DateInTray", "Failure to get drawable: " + name, e);
}
return( drawableId );
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en