Java Code Examples for android.widget.EditText#setLongClickable()

The following examples show how to use android.widget.EditText#setLongClickable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongolInputMethodManager.java    From mongol-library with MIT License 6 votes vote down vote up
private void setAllowSystemKeyboardOnEditText(EditText editText, boolean allowSystemKeyboard) {
    // TODO this needs to be tested on lower versions!
    // https://stackoverflow.com/a/45229457

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // api 21+
        editText.setShowSoftInputOnFocus(allowSystemKeyboard);
    } else { // api 11+
        if (allowSystemKeyboard) {
            // re-enable keyboard (see https://stackoverflow.com/a/45228867)
            // FIXME this does not necessarily always work
            editText.setTextIsSelectable(false);
            editText.setFocusable(true);
            editText.setFocusableInTouchMode(true);
            editText.setClickable(true);
            editText.setLongClickable(true);
            editText.setMovementMethod(ArrowKeyMovementMethod.getInstance());
            editText.setText(editText.getText(), TextView.BufferType.SPANNABLE);
        } else {
            // disable keyboard
            editText.setTextIsSelectable(true);
        }
    }
}
 
Example 2
Source File: DialpadView.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * Whether or not the digits above the dialer can be edited.
 *
 * @param canBeEdited If true, the backspace button will be shown and the digits EditText
 *                    will be configured to allow text manipulation.
 */
public void setDigitsCanBeEdited(boolean canBeEdited) {
    View deleteButton = findViewById(R.id.button_delete);
    deleteButton.setVisibility(canBeEdited ? View.VISIBLE : View.GONE);
    View callButton = findViewById(R.id.button_call);
    callButton.setVisibility(canBeEdited ? View.VISIBLE : View.GONE);
    EditText digits = (DigitsEditText) findViewById(R.id.digits_edit_text);
    digits.setClickable(canBeEdited);
    digits.setLongClickable(canBeEdited);
    digits.setFocusableInTouchMode(canBeEdited);
    digits.setCursorVisible(canBeEdited);
}