Java Android : onTouchListener release? -


java/android noob here, have problem using ontouchlistener change variable x x+1 , works fine, when release x variable decrease in value until hits zero, so:

    imageview image = (imageview) findviewbyid(r.id.fgview);      image.setontouchlistener(new view.ontouchlistener()     {          public boolean ontouch(view v, motionevent event)         {switch (event.getaction() & motionevent.action_mask)             {              case motionevent.action_down:                      mode=1;                  break;             case motionevent.action_up:                  mode=2;                  break;             case motionevent.action_pointer_up:                  mode2=2;                  break;             case motionevent.action_move:                  mode=1;                  break;             case motionevent.action_pointer_down:                  mode2=1;                  break;             }          }        if(mode==1){        x++;        }         if(mode==2){        x * 0.9        }         //mode2 filler       } 

now works fine, problem comes when want x continue decrease after release, since it's under setontouchlistener doesn't work. maybe this:

     public boolean ontouchfalse(view v){           if(x>0){               x * 0.9           }      } 

or like

     public boolean image.isonscreen{          if(x>0){             x = x * 0.9          }      } 

tl;dr: i'm looking kind of listener use depreciate x.

is there listener or class i'm missing? , help!

    final handler handler = new handler();       image.post( new runnable() {         @override         public void run() {              x--;             handler.postdelayed(this, 100);          }     }); 

** note 100 how long in between each subtraction (in millisecs)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -