//strings.xml <string-array name="ImageList"> <item>image1</item> <item>image2</item> <item>image3</item> </string-array> //mainactivity.java public void onClick(View v) { switch(v.getId()){ case R.id.btnNext: String[] ImageList = getResources().getStringArray(R.array.ImageList); if(iLoopCount == ImageList.length) { iLoopCount=0; } iLoopCount = iLoopCount+1; String imagename = ImageList[iLoopCount]; Toast.makeText(getApplicationContext(),imagename , Toast.LENGTH_SHORT).show(); ImageView imageView1 = (ImageView) findViewById(R.id.imageView1); int drawableID = getResources().getIdentifier("drawableName", "drawable", getPackageName()); Toast.makeText(getApplicationContext(),drawableID , Toast.LENGTH_SHORT).show(); imageView1.setImageResource(drawableID); //imageView1.setImageResource(drawableID); break; }
imageView1.setImageDrawable(drawableID);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)