Search in sources :

Example 1 with ContactEditText

use of com.rey.material.app.ContactEditText in project material by rey5137.

the class TextfieldFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_textfield, container, false);
    final EditText et_helper = (EditText) v.findViewById(R.id.textfield_et_helper);
    et_helper.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP)
                et_helper.setError("Password is incorrect.");
            return false;
        }
    });
    et_helper.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus)
                et_helper.setError(null);
        }
    });
    final EditText et_helper_error = (EditText) v.findViewById(R.id.textfield_et_helper_error);
    et_helper_error.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP)
                et_helper_error.setError("Password is incorrect.");
            return false;
        }
    });
    et_helper_error.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus)
                et_helper_error.setError(null);
        }
    });
    ContactEditText a = (ContactEditText) v.findViewById(R.id.textfield_tv);
    return v;
}
Also used : EditText(com.rey.material.widget.EditText) ContactEditText(com.rey.material.app.ContactEditText) KeyEvent(android.view.KeyEvent) ContactEditText(com.rey.material.app.ContactEditText) View(android.view.View) TextView(android.widget.TextView)

Aggregations

KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 TextView (android.widget.TextView)1 ContactEditText (com.rey.material.app.ContactEditText)1 EditText (com.rey.material.widget.EditText)1