for循环得到i的值,然后把这个值赋值给strValue?

解决方案 »

  1.   

    我的意思是当strValue=“"R.drawable.club_1”时,我怎么调用imageView1.setImageDrawable(getResources().getDrawable(R.drawable.card__club_1));不能 imageView1.setImageDrawable(getResources().getDrawable(strValue));这样写,应该怎么写呢?
      

  2.   

    strValue是图片是名字,即club_1...
    R.drawable.card__club_1是个整型,是对应club_1的索引。所以,strValue直接用图片的名字就可以了,得到对应的图片id通过context.getResources().getIdentifier(“club_1”, "drawable", context.getPackageName())获取.
      

  3.   

    把R.drawable.club_1到R.drawable.club_7放在一个int类型的数组中,如:int[] club = {R.drawable.club_1,R.drawable.club_2,R.drawable.club_3,R.drawable.club_4,R.drawable.club_5,R.drawable.club_6,R.drawable.club_7};
    imageView1.setImageDrawable(getResources().getDrawable(R.drawable.card__club_1));就可以写成 imageView1.setImageDrawable(getResources().getDrawable(club[0]));
      

  4.   

    把R1-R7的int放到数组中,使用时用数组的索引号兑取