resource using simple
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import com.sodonsolution.android.utils.ResourceUtils;
/**
* Created by IntelliJ IDEA.
* User: boroo
* Date: Dec 23, 2010
* Time: 10:29:42 AM
* To change this template use File | Settings | File Templates.
*/
public class ResourceManager {
protected String[] Errors;
public Resources getRes() {
return res;
}
public void setRes(Resources res) {
this.res = res;
if(res != null) {
Errors = getStringArray("news_errors");
}
}
private Resources res;
public ResourceManager() {
}
public String getError(int index) {
if (Errors.length <= index) {
return "Error is not found!";
} else {
return Errors[index];
}
}
public String getString(String resName) {
int i = res.getIdentifier(resName, "string", StaticConfigs.DEFAULT_RESOURCE_PACKAGE);
return res.getString(i);
}
public String[] getStringArray(String resName) {
int i = res.getIdentifier(resName, "array", StaticConfigs.DEFAULT_RESOURCE_PACKAGE);
return res.getStringArray(i);
}
public Drawable getDrawable(int i) {
return res.getDrawable(i);
}
public Drawable getDrawable(String resName) {
return res.getDrawable(res.getIdentifier(
resName,
"drawable",
StaticConfigs.DEFAULT_RESOURCE_PACKAGE
));
}
}
No comments:
Post a Comment