I can not compare view.getBackground() == R.drawable.image ?[android] -
i need compare image loaded background imageview. this:
@override public boolean ontouch(view v, motionevent event) { if(event.getaction() == motionevent.action_down) { switch (v.getid()) { case r.id.hero1: if(v.getbackground() == r.drawable.hero1){ //do } break; case r.id.hero2: //other stuff }
but v.getbackground() not compare have in drawable folder. why?
note v.getbackgroundresource() not available.
you can this-
@override public boolean ontouch(view v, motionevent event) { if(event.getaction() == motionevent.action_down) { switch (v.getid()) { case r.id.hero1: if (v.getbackground().getconstantstate().equals(getresources().getdrawable(r.drawable.hero1).getconstantstate())) { // here } break; case r.id.hero2: //other stuff }
Comments
Post a Comment