Android UI How to - Get color from Resource by id








Question

We would like to know how to get color from Resource by id.

Answer


import android.content.Context;

public class Main {
  public static int getColor(Context context,final int mColorId){
    return context.getResources().getColor(mColorId);
  }
}