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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -