I am a new in android programming. I want to set dynamically images in one xml, when this displayed. Specifically, i am storing my project related images in drawable folder. Also I am storing the image names in string variable and dynamically I am trying to set those images to the imageview. But the image is not displaying.
My code:
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.stone );
imageView = ( ImageView )findViewById( R.id.stone_xxxx );
Intent intent = getIntent();
position = intent.getStringExtra( "POSITION" );
if ( position == "0" )
{
int imageResource = getResources().getIdentifier( "@drawable/stone_a1", null, getPackageName() );
Drawable res = getResources().getDrawable(imageResource);
imageView.setImageDrawable( res );
}
}