将R.id分配给Array中的每个元素

时间:2017-06-20 02:55:12

标签: java android arrays arraylist

我使用Custom Adapter和ArrayList Data Type创建了这个ArrayList,如下所示,

ArrayList<Question> questionsArrayList = new ArrayList<>();
questionsArrayList.add(new Question("Question 1:", "What is his Favorite Color?", "Blue", "Green", "Red"));
questionsArrayList.add(new Question("Question 2:", "What is his Favorite Band of All Time?", "Linkin Park", "Led Zeppelin", "My Chemical Romance"));
questionsArrayList.add(new Question("Question 3:", "Where is his place of birth?", "Calamba, Laguna", "Barangka, Marikina", "Sampaloc, Manila"));
questionsArrayList.add(new Question("Question 4:", "Is he handsome?", "Yes", "Hollie Macaroni", "I think so"));

现在我的问题是,是否可以为每个数组的特定元素分配资源ID?假设我想将资源ID分配给“Blue”,“Led Zeppelin”,“Barangka,Marikina”和“Hollie Macaroni”。

有可能吗? 谢谢!

1 个答案:

答案 0 :(得分:0)

  

是否可以为每个Array的特定元素分配资源ID?

您可以将Integer(资源ID)映射到Question对象,是的。

  

让我们说我想将资源ID分配给&#34; Blue&#34;,&#34; Led Zeppelin&#34;,&#34; Barangka,Marikina&#34;和&# 34; Hollie Macaroni&#34;

听起来你想要R.string值,而不是R.id