set Error message to EditText on ScrollView - Android User Interface

Android examples for User Interface:EditText

Description

set Error message to EditText on ScrollView

Demo Code


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

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

public class Main {
    public static void setError(final ScrollView scrollView,
            final EditText editText, String errorMessage) {
        editText.requestFocus();//w  w w. ja v  a2 s  .c om
        if (scrollView != null) {
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    scrollView.smoothScrollTo(0, editText.getBottom());
                }
            });
        }
        editText.setError(errorMessage);
    }
}

Related Tutorials