Java 在一个while代码中设置所有int/imageresource/clicklistener ext

Java 在一个while代码中设置所有int/imageresource/clicklistener ext,java,android,image,while-loop,int,Java,Android,Image,While Loop,Int,我有30个整数。和30张图片。我想在一个代码中设置所有相同的设置 像这样(在Java中使用android) ) 我的int值类似于i0、i1、i2 int x = 0 ; while ( x<30) { //set ix = 0; x++; } 如何以编程方式使int/images相同 for(int x=0;x<30;x++) { ImageView img=(ImageView)findViewById(getResources().getIdentifier("a"+x

我有30个整数。和30张图片。我想在一个代码中设置所有相同的设置
像这样(在Java中使用android) )

我的int值类似于i0、i1、i2

int x = 0 ;
while ( x<30) {
//set ix = 0;
x++;
}
如何以编程方式使int/images相同

for(int x=0;x<30;x++)
{
   ImageView img=(ImageView)findViewById(getResources().getIdentifier("a"+x, "id", getPackageName()));
   img.setImageResource(getIdentifier("i"+x , "drawable", getPackageName()));
}
然后在循环中执行此操作

int num=myints.get("name"+x);

你可以对其他对象使用相同的方法,只要用你需要的对象替换
Integer

Android不是一种编程语言,它是一个平台。你用哪种语言?(看起来像C#或C++)
Map<String,Integer> myints=new HashMap<String,Integer>(){
   {
      put("nameX",0);
      put("nameX",1);
      ...and so on... 
   }
};
int num=myints.get("name"+x);