sharish/ScratchView

can not set imageresource

Closed this issue · 1 comments

can not set image resource programetically, if remove src from xml file and try to set src programetically using "scratchimageview.setimageresource" it displays nothing

It will work if you instantiate ScratchImageView by using findViewById. Please take a look at the snippet below:
ScratchImageView scratchImageView = (ScratchImageView) findViewById(R.id.sample_image);
Resources resources = getResources();
final int resourceID = resources.getIdentifier(b.getString("promoCode"), "drawable", getPackageName());
scratchImageView.setImageDrawable(resources.getDrawable(resourceID, null));