循环中的变量 Java

Variable in Loop Java

我有代码:

XmlResourceParser parser = context.getResources().getXml(R.xml.test1);

如何更改循环中的最后一个对象? (对象 = R.xml.test1)

比如我创建table:

int[] table = {(R.xml.test1), (R.xml.test2), (R.xml.test2)}

这是我要改变的对象。怎样才能做好呢?

也许循环你的table?

for (int resource : table) {
    XmlResourceParser parser = context.getResources().getXml(resource);
    //Do whatever you need to do with the parser
}