CardView 的 getResources() 出现 NullPointerException

NullPointerException on getResources() for a CardView

我有一个困扰我很多的问题...我需要在 Android 项目中的正常 java class 中调用字符串数组,但是为了爱天哪,我不知道如何在这里获取资源()...我尝试了 Google 中的一些 getContext 想法,但无济于事... java 文件用于加载 CardView 的元素有数据...如果需要请向我询问更多详细信息...

public class ChoicesManager {
private  static String[] ChoiceArray;
private static ChoicesManager mInstance;
private List<Choice> choices;



public static ChoicesManager getInstance() {
    if (mInstance == null) {
        mInstance = new ChoicesManager();
    }

    return mInstance;
}



public List<Choice> getChoices() {
    if (choices == null) {
        choices = new ArrayList<Choice>();
        ChoiceArray = mInstance.getResources().getStringArray(R.array.group_iteme); //HOW DO I FIX THIS

        for (String choiceName : ChoiceArray) {
            Choice choice = new Choice();
            choice.name = choiceName;
            choice.imageName = choiceName.replaceAll("\s+","").toLowerCase();
            choices.add(choice);
        }
    }

    return  choices;
}

}

I can't figure out how to getResources()

为了正常访问getResources() java class 需要使用Context。获取 Context 将 Context 参数添加到 getChoices 方法:

public List<Choice> getChoices(Context mContext) {
    //...
    ChoiceArray = mContext.getResources().getStringArray(R.array.group_iteme);
   //....
    return  choices;
}