onTouchListener Hover Effect

 onTouchListener Hover Effect


Hover effect when you touch the view and release it. Like when I touch it the button the button text will be "TOUCHING..." and after I release it it will be "Touched, done".

Codes:
button1.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_DOWN){
     // PUT YOUR CODE HERE WHEN TOUCHING, ILL PUT MINE
     button1.setText("TOUCHING...");
}
if(event.getAction() == MotionEvent.ACTION_UP){
     // PUT YOUR SECOND CODE HERE WHEN RELEASED
     button1.setText("TOUCHED");
}
                return false;
            }
        });

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Bro how can u give me game project

    ReplyDelete

Post a Comment

Popular posts from this blog

Number with Comma (9,999)

Get Percent of the Number (98%)

Get X, Y Position of Layout