resources - How to check what photo is currently presented on the screen by ImageView (in android)? -
a bit wierd problem:
is possible id or/and name of active resource in imageview? that's code.
imageview photo = (imageview) findviewbyid(r.id.placeforphoto); //here choose random photo drawable (photo 1 photo 10) //and show on screen below photo.setimageresource(r.drawable.photo1); //or photo2 or photo3 or... in other part of code check photo atm presented in placeforphoto. if it's r.drawable.photo1 or r.drawable.photo2 or...
so need smth have possibility achieve such comparison:
if ([presented atm photo in imagview photo] == r.drawable.photo1) {do something} else if ([presented atm photo in imagview photo] == r.drawable.photo2) {do smth different} else {...} i tried: photo.getid() returns id of placeforphoto not resource inside;
photo.getresource() returns other value different id of photo
getresource().getidentifier() gives id when have name , don't have name (or maybe it's possible name imageview photo?)
getresources().getresourcename() have have id i'm looking for.
thx in advance.
is possible id or/and name of active resource in imageview?
no, because imageview not have hold resource. hold bitmap obtained other means (e.g., download web).
so need smth have possibility achieve such comparison
store id in data member of activity, or in tag of imageview (i.e., settag() , gettag()).
Comments
Post a Comment