Code example for EditText

Methods: setHintsetInputTypesetText, requestFocus, setOnFocusChangeListener

0
            mHint = object.optString("hint");
            mAutofocus = object.optBoolean("autofocus");
        } 
 
        public View getView(final Context context) throws UnsupportedOperationException {
            EditText input = new EditText(context);
            input.setInputType(InputType.TYPE_CLASS_TEXT);
            input.setText(mValue);
 
            if (!TextUtils.isEmpty(mHint)) {
                input.setHint(mHint);
            } 
 
            if (mAutofocus) {
                input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                    @Override 
                    public void onFocusChange(View v, boolean hasFocus) {
                        if (hasFocus) {
                            ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(v, 0);
                        } 
                    } 
                }); 
                input.requestFocus();
            } 
 
            mView = (View)input;
            return mView;
        } 
 
        public String getValue() {
            EditText edit = (EditText)mView;
            return edit.getText().toString();
        } 
    } 
 
    public static class PasswordInput extends EditInput { 
        public static final String INPUT_TYPE = "password";
        public PasswordInput(JSONObject obj) {
            super(obj);
        } 
 
        public View getView(Context context) throws UnsupportedOperationException {
            EditText input = (EditText) super.getView(context);
            input.setInputType(InputType.TYPE_CLASS_TEXT |
                               InputType.TYPE_TEXT_VARIATION_PASSWORD |
                               InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            return input;
        }