Skip to main content

Posts

Showing posts from October, 2018

How to set an ATM Input EditText

This tutorial will show you how to form an ATM Input EditText Let's see how to do this Create your xml with a EditText <EditText     android:id="@+id/id_edttext_amt"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:text="$0.00"     android:gravity="center"     android:inputType="number"/> Now in you activity, Implement TextWatcher for the EditText you need ATM type input private String current = ""; edtAtm.addTextChangedListener(new TextWatcher() {     @Override     public void beforeTextChanged(CharSequence s, int start, int count, int after{     }     @Override     public void onTextChanged(CharSequence s, int start, int before, int count) {         if(!s.toString().equals(current)){             edtAtm.removeTextChangedListener(this);   ...

How to work with Swipe Gestures in Android

Gesture? Gestures in android is defined as the movements of your fingers on android device screen and respond accordingly if there is any listener is implemented for gesture detection. In this article we can see how to do action by SwipeTop , SwipeBottom , SwipeRight , SwipeLeft . Let's Start Create a class  OnSwipeTouchListener public class OnSwipeTouchListener implements View.OnTouchListener { private final GestureDetector gestureDetector = new GestureDetector( new GestureListener()); public boolean onTouch( final View v, final MotionEvent event) { return gestureDetector .onTouchEvent(event); } private final class GestureListener extends GestureDetector.SimpleOnGestureListener { private static final int SWIPE_THRESHOLD = 100 ; private static final int SWIPE_VELOCITY_THRESHOLD = 100 ; @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { boolean resu...