I am writing a Static method that returns the required Drawable by parameter. How can I get Drawable by id without getting Context ? Those. getting only a String ?
public static Drawable getDrawableByString(Context context, String color) { Drawable retDrawable = ContextCompat.getDrawable(context, R.drawable.round_transparent); switch (color) { case "RED": retDrawable = ContextCompat.getDrawable(context, R.drawable.round_darkred); break; case "BLUE": retDrawable = ContextCompat.getDrawable(context, R.drawable.round_blue); break; } return retDrawable; }
Drawable retDrawable = Resources.getSystem().getDrawable(R.drawable.round_transparent)? But in general it is not good. - post_zeew 2:46 pm