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

The following examples show how to use android.widget.EditText#setSelectAllOnFocus() . 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: RenameDialog.java    From GreenDamFileExploere with Apache License 2.0 6 votes vote down vote up
private void init() {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_name_input, null);
    mView = view.findViewById(R.id.rename_dialog_root);
    this.setContentView(mView);
    mEtNewName = (EditText) mView.findViewById(R.id.mEtNewName);
    mEtOrignalName = (EditText) mView.findViewById(R.id.mEtOriginalName);
    mBtnCancel = (Button) mView.findViewById(R.id.mBtnDelDialogCancel);
    mBtnOk = (Button) mView.findViewById(R.id.mBtnDelDialogOk);
    
    mEtOrignalName.setEnabled(false);
    mEtOrignalName.setText(FileUtils.getFileName(mOrignalPath));
    mEtNewName.setText(FileUtils.getFileName(mOrignalPath));
    mEtNewName.setSelectAllOnFocus(true);
    mParentPath = FileUtils.getParent(mOrignalPath);
    
    mEtNewName.addTextChangedListener(this);
    mBtnOk.setOnClickListener(this);
    mBtnCancel.setOnClickListener(this);
    this.setTitle("重命名文件");
    this.setCanceledOnTouchOutside(false);
    
}
 
Example 2
Source File: DropEditText.java    From DropEditText with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
	super.onFinishInflate();
	
	mEditText = (EditText) findViewById(R.id.dropview_edit);
	mDropImage = (ImageView) findViewById(R.id.dropview_image);
	
	mEditText.setSelectAllOnFocus(true);
	mDropImage.setImageResource(mDrawableLeft);

	if(!TextUtils.isEmpty(mHit)) {
		mEditText.setHint(mHit);
	}
	
	mDropImage.setOnClickListener(this);
	mPopView.setOnItemClickListener(this);
}
 
Example 3
Source File: MiscTweaksActivity.java    From Kernel-Tuner with GNU General Public License v3.0 6 votes vote down vote up
private void showSetReadAheadDialog(Misc misc)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle(R.string.read_ahead_cache_size);

    final EditText input = new EditText(this);
    input.setText(misc.getValue().substring(0, misc.getValue().length() - 2));
    input.setSelectAllOnFocus(true);
    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    input.setGravity(Gravity.CENTER_HORIZONTAL);
    input.requestFocus();

    builder.setPositiveButton(getResources().getString(R.string.set), new DialogInterface.OnClickListener()
    {
        @Override
        public void onClick(DialogInterface dialog, int which)
        {
            RCommand.setReadAhead(input.getText().toString(), MiscTweaksActivity.this);
        }
    });
    builder.setNegativeButton(getResources().getString(R.string.cancel), null);
    builder.setView(input);
    builder.show();
}
 
Example 4
Source File: DialogHelper.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
public static void askString (final Context context, final String msg,
		final String oldValue, final boolean multiLine, final boolean spellCheck,
		final Listener<String> onString) {
	final AlertDialog.Builder dlgBld = new AlertDialog.Builder(context);
	dlgBld.setMessage(msg);
	final EditText editText = new EditText(context);
	editText.setSelectAllOnFocus(true);
	if (oldValue != null) editText.setText(oldValue);
	if (!multiLine) editText.setSingleLine();
	if (!spellCheck) editText.setInputType(editText.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
	editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
	dlgBld.setView(editText);
	dlgBld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
		@Override
		public void onClick (final DialogInterface dialog, final int which) {
			dialog.dismiss();
			onString.onAnswer(editText.getText().toString().trim());
		}
	});
	dlgBld.setNegativeButton(android.R.string.cancel, DLG_CANCEL_CLICK_LISTENER);
	dlgBld.show();
}
 
Example 5
Source File: RenameCollectionDialogFragment.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction

    String oldName = getArguments().getString(KEY_OLD_NAME);


    String collectionSerialized = getArguments().getString(KEY_COLLECTION_GSON);
    Gson gson = new Gson();
    BooksCollection bookCollection = gson.fromJson(collectionSerialized, BooksCollection.class);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final EditText editText = new EditText(getActivity());
    editText.setText(oldName);
    editText.setSelectAllOnFocus(true);
    builder
            .setMessage(R.string.dialog_msg_rename)
            .setTitle(R.string.dialog_title_rename)
            .setView(editText)
            .setPositiveButton(R.string.ok, (dialog, whichButton) -> {
                String newName = editText.getText().toString();
                mListener.onCollectionRenamed(bookCollection, newName);
            })
            .setNegativeButton(R.string.cancel, (dialog, whichButton) -> {
                dismiss();
            });
    return builder.create();
}
 
Example 6
Source File: CommentMeasurementView.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example 7
Source File: PromptDialog.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PromptDialog(Context context) {
    super(context);
    finder = ResoureFinder.getInstance(context);
    final LayoutInflater inflater = LayoutInflater.from(getContext());
    final RelativeLayout layout = (RelativeLayout) inflater.inflate(
            finder.getLayoutId("platform_window_dialog_prompt_layout"), null);
    tvDesc = (TextView) layout.findViewById(finder.getId("tv_dialog_input_desc"));
    etInput = (EditText) layout.findViewById(finder.getId("et_dialog_input_text"));
    etInput.setSelectAllOnFocus(true);
    setView(layout);
}
 
Example 8
Source File: LoginActivity.java    From SendBird-Android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_login);

    EditText etUserId = findViewById(R.id.etUserId);
    EditText etNickname = findViewById(R.id.etNickname);
    TextView tvVersion = findViewById(R.id.tvVersionInfo);

    etUserId.setSelectAllOnFocus(true);
    etNickname.setSelectAllOnFocus(true);

    String sdkVersion = String.format(getResources().getString(R.string.text_version_info), BuildConfig.VERSION_NAME, SendBird.getSDKVersion());
    tvVersion.setText(sdkVersion);

    findViewById(R.id.btSignIn).setOnClickListener(v -> {
        String userId = etUserId.getText().toString();
        // Remove all spaces from userID
        userId = userId.replaceAll("\\s", "");

        String userNickname = etNickname.getText().toString();
        if (TextUtils.isEmpty(userId) || TextUtils.isEmpty(userNickname)) {
            return;
        }

        PreferenceUtils.setUserId(userId);
        PreferenceUtils.setNickname(userNickname);

        WaitingDialog.show(this);
        SendBirdUIKit.connect((user, e) -> {
            if (e != null) {
                Logger.e(e);
                WaitingDialog.dismiss();
                return;
            }
            WaitingDialog.dismiss();
            PushUtils.registerPushHandler(new MyFirebaseMessagingService());
            Intent intent = new Intent(LoginActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        });
    });
}