Android - referencing string array using another string with getIdentifier() and getStringArray

后端 未结 1 466
野趣味
野趣味 2021-01-04 11:34

I have a variety of string arrays I want to access depending on which one the user decides to use. I don\'t want to use a SQLite DB because I am very new to Android/Java an

相关标签:
1条回答
  • 2021-01-04 12:10

    Shouldn't this line be like this?

    int holderint = getResources().getIdentifier(name, "array",
                    this.getPackageName()); // You had used "name"
    String[] items = getResources().getStringArray(holderint);
    
    0 讨论(0)
提交回复
热议问题