java - OnTouchListener return value -
i'm trying understand full ontouchlistener
, have doubts.
i have xml code:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.pablo.mainactivity" tools:ignore="mergerootframe" > <button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" /> </linearlayout>
and have implemented code java:
public class mainactivity extends activity { button b; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); b = (button)findviewbyid(r.id.button1); b.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { switch (arg1.getaction()) { case motionevent.action_down: toast.maketext(getbasecontext(), "boton down",toast.length_short).show(); break; case motionevent.action_up: toast.maketext(getbasecontext(), "boton up",toast.length_short).show(); break; } return false; } }); } }
i have read when return false in action_down
, rest of gesture (move
, up
) doesn't work. works in code, "up" message shown on screen, , shouldn't. don't understand meaning of return value in ontouch
event.
can helps me?
assuming question "what return value mean on ontouch"?
if looked @ documentation, see;
returns true if listener has consumed event, false otherwise.
have @ documentation here.
Comments
Post a Comment