Created
June 24, 2013 03:54
-
-
Save pec1985/5847653 to your computer and use it in GitHub Desktop.
Helper to get R. in Titanium Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.pec1985.tigolf; | |
import org.appcelerator.titanium.util.TiRHelper; | |
import org.appcelerator.titanium.util.TiRHelper.ResourceNotFoundException; | |
public class RHelper { | |
public static int getString(String str){ | |
try { | |
return TiRHelper.getApplicationResource("string."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static int getLayout(String str){ | |
try { | |
return TiRHelper.getApplicationResource("layout."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static int getId(String str){ | |
try { | |
return TiRHelper.getApplicationResource("id."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static int getDrawable(String str){ | |
try { | |
return TiRHelper.getApplicationResource("drawable."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static int getColor(String str){ | |
try { | |
return TiRHelper.getApplicationResource("color."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static int getRaw(String str){ | |
try { | |
return TiRHelper.getApplicationResource("raw."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
public static int getXML(String str){ | |
try { | |
return TiRHelper.getApplicationResource("xml."+str); | |
} catch (ResourceNotFoundException e) { | |
e.printStackTrace(); | |
return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment