android - Perform a method continuously when button is in pressed state -
i trying perform method long button pressed.
public void onclick(view view) { method(); }
the above code performs method once if press , hold button trying perform method continuously long button in pressed state.
<?xml version="1.0" encoding="utf-8"?> <button xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/button_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_send" android:onclick="onclick" />
you can write while loop in method() want execute. while exit when action_up
received.
work:
boolean pressed = true; private void method() { while(pressed) { //code } }
set boolean pressed false when action_up
.
Comments
Post a Comment