Example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Prototype

int IME_ACTION_DONE

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "done" operation, typically meaning there is nothing more to input and the IME will be closed.

Usage

From source file:com.ibm.mil.readyapps.summit.fragments.CreateListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View layout = inflater.inflate(R.layout.fragment_create_list, container, false);

    getActivity().setTitle(getString(R.string.create_list_title));

    // submit list name when user clicks 'Done' key on soft keyboard
    mEnterListName = (EditText) layout.findViewById(R.id.enter_list_name);
    mEnterListName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//  w w  w  .j a  va  2 s.  c  o m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                createList(v.getText().toString());
                return true;
            }

            return false;
        }
    });

    // configure UI depending on display mode
    if (isOverlayMode()) {
        TextView createNewList = (TextView) layout.findViewById(R.id.create_new_list);
        createNewList.setTypeface(FontCache.getFont(getActivity(), FontCache.FontName.OSWALD_REGULAR));

        ImageButton backButton = (ImageButton) layout.findViewById(R.id.back_button);
        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getFragmentManager().popBackStackImmediate();
            }
        });

        mEnterListName.setHint(getString(R.string.list_name_hint));
    } else {
        View overlayHeader = layout.findViewById(R.id.overlay_header);
        overlayHeader.setVisibility(View.GONE);
    }

    return layout;
}

From source file:com.iutiao.sdk.dialogs.LoginDialog.java

public void updateUI() {
    //        Validate.notNull(signinBtn, "signinBtn");
    signinBtn.setEnabled(false);//from  w ww .  j a va 2 s. c om
    usernameEt.setText(Utility.getMyPhoneNumber());
    usernameEt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                passwordEt.requestFocus();
            }
            return true;
        }
    });

    passwordEt.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 (passwordEt.getText().toString().length() >= 6) {
                signinBtn.setEnabled(true);
            } else if (signinBtn.isEnabled()) {
                signinBtn.setEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    signinBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = getInputUsername();
            if (Validate.isEmailValid(username) || Validate.isPhoneValid(username, "CN")) {
                performSignin();
            } else {
                Log.i("REG", "username " + username + " isEmailValid " + Validate.isEmailValid(username)
                        + " isPhoneValid " + Validate.isPhoneValid(username, "CN"));
                usernameEt.setError(getActivity().getString(R.string.com_iutiao_error_invalid_email_or_phone));
            }
        }
    });

    quickRegisterTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fragment.showQuickRegisterDialog();
        }
    });

    forgotPassTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fragment.showResetPasswordDialog();
        }
    });

}

From source file:io.upnext.beaconcontrol.app.LoginActivity.java

private void wireViews() {
    emailEditText = (EditText) findViewById(R.id.email);
    passwordEditText = (EditText) findViewById(R.id.password);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from   w  w  w . j  a  v a 2  s.c  o m*/
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                logIn();
            }
            return false;
        }
    });
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);

    Button loginButton = (Button) findViewById(R.id.login_btn);
    loginButton.setOnClickListener(loginButtonListener);

    TextView createAccountLink = (TextView) findViewById(R.id.create_account);
    createAccountLink.setPaintFlags(createAccountLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    createAccountLink.setOnClickListener(createAccountListener);
}

From source file:pl.bcichecki.rms.client.android.dialogs.RemindPasswordDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    context = getActivity();/*  w ww.j a v  a  2 s .  c  o  m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getString(R.string.dialog_remind_password_title));
    builder.setMessage(getString(R.string.dialog_remind_password_message));

    final LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    int space = (int) AppUtils.convertDpToPixel(getActivity(), 16);
    layout.setPadding(space, 0, space, 0);

    final EditText usernameEditText = new EditText(getActivity());
    usernameEditText.setHint(getString(R.string.dialog_remind_password_enter_username_hint));
    usernameEditText.setMaxLines(1);
    usernameEditText.setSingleLine();
    usernameEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    usernameEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            usernameEditText.setError(null);
        }
    });
    layout.addView(usernameEditText);

    builder.setView(layout);

    builder.setPositiveButton(getString(R.string.dialog_remind_password_ok),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    return;
                }
            });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            utilitiesRestClient = new UtilitiesRestClient(getActivity(),
                    SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(),
                    SharedPreferencesWrapper.getWebserviceContextPath());

            final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!AppUtils.checkInternetConnection(getActivity())) {
                        Log.d(TAG, "There is NO network connected!");
                        return;
                    }

                    usernameEditText.setError(null);

                    if (StringUtils.isBlank(usernameEditText.getText().toString())) {
                        usernameEditText.setError(getString(R.string.dialog_remind_password_field_required));
                        return;
                    }

                    final String username = usernameEditText.getText().toString();

                    utilitiesRestClient.forgotPassword(username, new AsyncHttpResponseHandler() {

                        @Override
                        public void onFailure(Throwable error, String content) {
                            Log.d(TAG, "Reminding password failed. [error=" + error + ", content=" + content
                                    + "]");
                            AppUtils.showCenteredToast(context,
                                    getString(R.string.dialog_remind_password_recovery_failed),
                                    Toast.LENGTH_LONG);
                        }

                        @Override
                        public void onFinish() {
                            positiveButton.setEnabled(true);
                        }

                        @Override
                        public void onStart() {
                            Log.d(TAG, "Reminding password for user: " + username);
                            AppUtils.showCenteredToast(context,
                                    getString(R.string.dialog_remind_password_recovery_in_progress),
                                    Toast.LENGTH_SHORT);
                            positiveButton.setEnabled(false);
                        }

                        @Override
                        public void onSuccess(int statusCode, String content) {
                            Log.d(TAG, "Reminding password success.");
                            AppUtils.showCenteredToast(context,
                                    getString(R.string.dialog_remind_password_recovery_successful),
                                    Toast.LENGTH_SHORT);
                            dialog.dismiss();
                        }

                    });

                }
            });

            final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            negativeButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    cancelRequests();
                    dialog.dismiss();
                }
            });

        }
    });

    return dialog;
}

From source file:org.oucho.whois.MainActivity.java

private void run() {

    EditText urlText = (EditText) findViewById(R.id.editHostName);

    assert urlText != null;
    urlText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override// w  ww. j a v a  2 s  .c o  m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                whoisMessage(v);
            }
            return false;
        }
    });
}

From source file:com.forrestguice.suntimeswidget.settings.ColorChooser.java

public ColorChooser(final Context context, TextView txtLabel, EditText editField, ImageButton imgButton,
        String id) {/*from   w w w.  java2 s .  c om*/
    chooserID = id;

    label = txtLabel;
    if (label != null) {
        label.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onFocusGained(v);
            }
        });
    }

    edit = editField;
    if (edit != null) {
        edit.addTextChangedListener(this);
        edit.setOnFocusChangeListener(this);

        edit.setOnEditorActionListener(new EditText.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    changeColor();
                    return true;
                }
                return false;
            }
        });

    }

    inputSet = new HashSet<>();
    for (char c : alphabet) {
        inputSet.add(c);
    }

    button = imgButton;
    if (button != null) {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (label != null) {
                    label.requestFocus();
                }
                showColorPicker(context);
            }
        });
    }
}

From source file:com.waz.zclient.pages.main.profile.preferences.dialogs.ChangeEmailPreferenceDialogFragment.java

@SuppressLint("InflateParams")
@Override/* w  ww.  j  a v a2  s. co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = LayoutInflater.from(getActivity());
    final View view = inflater.inflate(R.layout.preference_dialog_change_email, null);

    inputLayout = ViewUtils.getView(view, R.id.til__preferences__email);
    final EditText editText = ViewUtils.getView(view, R.id.acet__preferences__email);
    editText.requestFocus();
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                handleInput();
                return true;
            } else {
                return false;
            }
        }
    });
    final String existingEmail = getArguments().getString(ARG_EMAIL, "");
    editText.setText(existingEmail);
    editText.setSelection(editText.length());

    final AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.pref__account_action__dialog__change_email__title).setView(view)
            .setPositiveButton(android.R.string.ok, null).setNegativeButton(android.R.string.cancel, null)
            .create();
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return alertDialog;
}

From source file:com.waz.zclient.pages.main.profile.preferences.dialogs.AddEmailAndPasswordPreferenceDialogFragment.java

@SuppressLint("InflateParams")
@Override/*from  w w w. j av  a  2s. co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = LayoutInflater.from(getActivity());
    final View view = inflater.inflate(R.layout.preference_dialog_add_email_password, null);

    emailInputLayout = ViewUtils.getView(view, R.id.til__preferences__email);
    final EditText emailEditText = ViewUtils.getView(view, R.id.acet__preferences__email);
    emailEditText.requestFocus();
    emailEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                emailInputLayout.getEditText().requestFocus();
                return true;
            } else {
                return false;
            }
        }
    });

    passwordInputLayout = ViewUtils.getView(view, R.id.til__preferences__password);
    final EditText passwordEditText = ViewUtils.getView(view, R.id.acet__preferences__password);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                handleInput();
                return true;
            } else {
                return false;
            }
        }
    });

    final AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.pref__account_action__dialog__add_email_password__title).setView(view)
            .setPositiveButton(android.R.string.ok, null).setNegativeButton(android.R.string.cancel, null)
            .create();
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return alertDialog;
}

From source file:com.google.cast.samples.games.gamedebugger.PlayerTransitionDialogFragment.java

@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
        onOkPressed();/*from  w w w.jav  a  2 s . co m*/
        return true;
    }
    return false;
}

From source file:es.uniovi.imovil.fcrtrainer.HexadecimalExerciseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView;//  w w  w .j  a v a 2  s.c o m
    rootView = inflater.inflate(R.layout.fragment_hexadecimal, container, false);

    etAnswer = (EditText) rootView.findViewById(R.id.answer);
    bChange = (Button) rootView.findViewById(R.id.change);
    bSolution = (Button) rootView.findViewById(R.id.seesolution);
    bCheck = (Button) rootView.findViewById(R.id.checkbutton);
    tvNumberToConvert = (TextView) rootView.findViewById(R.id.numbertoconvert);
    tvTitle = (TextView) rootView.findViewById(R.id.exercisetitle);
    tvPoints = (TextView) rootView.findViewById(R.id.tvpoints);
    randomGenerator = new Random();

    etAnswer.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (EditorInfo.IME_ACTION_DONE == actionId) {
                if (tohex)
                    isCorrect(etAnswer.getEditableText().toString().trim().toLowerCase(Locale.US));
                else
                    isCorrect(etAnswer.getEditableText().toString().trim());
            }
            return false;
        }
    });

    bCheck.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (tohex)
                isCorrect(etAnswer.getEditableText().toString().trim().toLowerCase(Locale.US));
            else
                isCorrect(etAnswer.getEditableText().toString().trim());
        }
    });

    bChange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            tohex ^= true;
            if (tohex) {
                setKeyboardLayout();
                setTitle();
            } else {
                setKeyboardLayout();
                setTitle();
            }
            generateRandomNumber();
        }
    });

    bSolution.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            showSolution();
        }
    });

    if (savedInstanceState != null) {
        tohex = savedInstanceState.getBoolean("tohex");
        numberToConvert = savedInstanceState.getInt("numbertoconvert");
        updateUI();
        setKeyboardLayout();
        setTitle();
    } else
        generateRandomNumber();

    return rootView;
}