/** * Set the TextView so that when it takes focus, all the text is * selected. * * @attr ref android.R.styleable#TextView_selectAllOnFocus */ public void setSelectAllOnFocus (boolean selectAllOnFocus){ mInputView.setSelectAllOnFocus(selectAllOnFocus); }
mEditText.setText(getDefaultValue()); mEditText.setSelectAllOnFocus(true); mEditText.requestFocus();
public UrlBarController(EditText editor, ImageView secureIcon) { mEditor = editor; mSecureIcon = secureIcon; mEditor.setOnFocusChangeListener(this); mEditor.setSelectAllOnFocus(true); }
@Override protected View getInputView() { EditText input = new EditText(getContext()); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE | InputType.TYPE_TEXT_FLAG_MULTI_LINE); input.setHint(R.string.info_enter_comment); input.setText(getValueAsString(false)); input.setSelectAllOnFocus(true); return input; }
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(super.mContext); dialogBuilder.setTitle( super.mContext.getResources().getString(R.string.FAVORITE_RENAME_DIALOG_TITLE)); dialogBuilder.setMessage( super.mContext.getResources().getString(R.string.FAVORITE_RENAME_DIALOG_MESSAGE)); final EditText input = new EditText(super.mContext); input.setInputType( InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE); input.setText(name); input.setSelectAllOnFocus(true); input.setHint(super.mContext.getResources().getString(R.string.FAVORITE_DIALOG_HINT)); input.setFilters( new InputFilter[]{new DialogInputFilter(), new InputFilter.LengthFilter(20)}); dialogBuilder.setView(input); dialogBuilder.setNeutralButton( super.mContext.getResources().getString(R.string.FAVORITE_RENAME_DIALOG_POSITIVE), new UpdateFavoriteListNameOnClickListener(name, favListId, input, (Activity) super.mContext, this) ); dialogBuilder.setNegativeButton( super.mContext.getResources().getString(R.string.FAVORITE_DIALOG_NEGATIVE), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } } );
shortname.setSelectAllOnFocus(true); fullname.setSelectAllOnFocus(true);
public InputLayout(Context context, TextView textView, EditText editText, int accentColor) { mContext = context; mScreenDensity = DisplayUtil.getScreenDensity(context); mTextView = textView; mEditText = editText; mAccentColor = accentColor; black_26p = ContextCompat.getColor(mContext, R.color.black_26p); setColors(black_26p); mEditText.setSelectAllOnFocus(true); mEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { raiseLabel(true); setColors(mAccentColor); mTextView.setTypeface(Typeface.DEFAULT_BOLD); } else { if (mEditText.getText().toString().isEmpty()) { InputLayout.this.fallLabel(); } setColors(black_26p); mTextView.setTypeface(Typeface.DEFAULT); } if (mOnFocusChangeListener != null) { mOnFocusChangeListener.onFocusChange(v, hasFocus); } } }); DisplayUtil.setSelectionHandlersColor(mEditText, accentColor); }
editTextName.setClickable(true); editTextName.setFocusableInTouchMode(true); editTextName.setSelectAllOnFocus(true); editTextName.setSingleLine(true); editTextName.setImeOptions(EditorInfo.IME_ACTION_NEXT); editTextPassword.setClickable(true); editTextPassword.setFocusableInTouchMode(true); editTextPassword.setSelectAllOnFocus(true); editTextPassword.setSingleLine(true); editTextPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.graph_preferences); EditTextPreference regressionLineOrder = (EditTextPreference) findPreference(PREFERENCE_KEY_REGRESSION_LINE_ORDER); regressionLineOrder.getEditText().setKeyListener(new DigitsKeyListener()); regressionLineOrder.getEditText().setSelectAllOnFocus(true); regressionLineOrder.setSummary(regressionLineOrder.getText()); regressionLineOrder.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { preference.setSummary((String) newValue); return true; } }); } }
editText.setSelectAllOnFocus(true);