clear Form Errors Animation - Android android.animation

Android examples for android.animation:Animation

Description

clear Form Errors Animation

Demo Code


//package com.java2s;
import android.os.Handler;

import android.widget.EditText;
import android.widget.ScrollView;

public class Main {
    public static void clearErrors(EditText... editTexts) {
        for (EditText editText : editTexts) {
            editText.setError(null);//from www .  ja  v a2  s .  c  o m
        }
    }

    public static void setError(final ScrollView scrollView,
            final EditText editText, String errorMessage) {
        editText.requestFocus();
        if (scrollView != null) {
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    scrollView.smoothScrollTo(0, editText.getBottom());
                }
            });
        }
        editText.setError(errorMessage);
    }
}

Related Tutorials