循环Java中的变量 [英] Variable in Loop Java

查看:69
本文介绍了循环Java中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码:

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

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

How to change last object in loop? (object = R.xml.test1)

例如,我创建表:

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

这是我要更改的对象.如何正确执行?

and this my object to change. How can do it properly?

推荐答案

也许循环遍历您的表?

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

这篇关于循环Java中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆