Java Code Examples for androidx.appcompat.widget.AppCompatEditText#append()

The following examples show how to use androidx.appcompat.widget.AppCompatEditText#append() . 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: EditorActivity.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_editor);

    initToolBar();
    String title = getIntent().getStringExtra(TITLE_INTENT);
    if (title != null) {
        Objects.requireNonNull(getSupportActionBar()).setTitle(title);
    }

    CharSequence text = getIntent().getCharSequenceExtra(TEXT_INTENT);
    mEditText = (AppCompatEditText) findViewById(R.id.edittext);
    if (text != null) {
        mEditText.append(text);
    }
}
 
Example 2
Source File: ViewUtils.java    From SmartFlasher with GNU General Public License v3.0 5 votes vote down vote up
public static Dialog dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
                                    final OnDialogEditTextListener onDialogEditTextListener, int inputType,
                                    Context context) {
    LinearLayout layout = new LinearLayout(context);
    int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
    layout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText editText = new AppCompatEditText(context);
    editText.setGravity(Gravity.CENTER);
    editText.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (text != null) {
        editText.append(text);
    }
    editText.setSingleLine(true);
    if (inputType >= 0) {
        editText.setInputType(inputType);
    }

    layout.addView(editText);

    Dialog dialog = new Dialog(context).setView(layout);
    if (negativeListener != null) {
        dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
    }
    if (onDialogEditTextListener != null) {
        dialog.setPositiveButton(context.getString(R.string.ok), (dialog1, which)
                -> onDialogEditTextListener.onClick(Objects.requireNonNull(editText.getText()).toString()))
                .setOnDismissListener(dialog1 -> {
                    if (negativeListener != null) {
                        negativeListener.onClick(dialog1, 0);
                    }
                });
    }
    return dialog;
}
 
Example 3
Source File: ViewUtils.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 5 votes vote down vote up
public static Dialog dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
                                    final OnDialogEditTextListener onDialogEditTextListener, int inputType,
                                    Context context) {
    LinearLayout layout = new LinearLayout(context);
    int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
    layout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText editText = new AppCompatEditText(context);
    editText.setGravity(Gravity.CENTER);
    editText.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (text != null) {
        editText.append(text);
    }
    editText.setSingleLine(true);
    if (inputType >= 0) {
        editText.setInputType(inputType);
    }

    layout.addView(editText);

    Dialog dialog = new Dialog(context).setView(layout);
    if (negativeListener != null) {
        dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
    }
    if (onDialogEditTextListener != null) {
        dialog.setPositiveButton(context.getString(R.string.ok), (dialog1, which)
                -> onDialogEditTextListener.onClick(Objects.requireNonNull(editText.getText()).toString()))
                .setOnDismissListener(dialog1 -> {
                    if (negativeListener != null) {
                        negativeListener.onClick(dialog1, 0);
                    }
                });
    }
    return dialog;
}
 
Example 4
Source File: ViewUtils.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
public static Dialog dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
                                    final OnDialogEditTextListener onDialogEditTextListener, int inputType,
                                    Context context) {
    LinearLayout layout = new LinearLayout(context);
    int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
    layout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText editText = new AppCompatEditText(context);
    editText.setGravity(Gravity.CENTER);
    editText.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (text != null) {
        editText.append(text);
    }
    editText.setSingleLine(true);
    if (inputType >= 0) {
        editText.setInputType(inputType);
    }

    layout.addView(editText);

    Dialog dialog = new Dialog(context).setView(layout);
    if (negativeListener != null) {
        dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
    }
    if (onDialogEditTextListener != null) {
        dialog.setPositiveButton(context.getString(R.string.ok), (dialog1, which)
                -> onDialogEditTextListener.onClick(editText.getText().toString()))
                .setOnDismissListener(dialog1 -> {
                    if (negativeListener != null) {
                        negativeListener.onClick(dialog1, 0);
                    }
                });
    }
    return dialog;
}
 
Example 5
Source File: ViewUtils.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 4 votes vote down vote up
public static Dialog dialogEditTexts(String text, String text2, String hint, String hint2,
                                     final DialogInterface.OnClickListener negativeListener,
                                     final onDialogEditTextsListener onDialogEditTextListener,
                                     Context context) {
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
    layout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText editText = new AppCompatEditText(context);
    editText.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (text != null) {
        editText.append(text);
    }
    if (hint != null) {
        editText.setHint(hint);
    }
    editText.setSingleLine(true);

    final AppCompatEditText editText2 = new AppCompatEditText(context);
    editText2.setLayoutParams(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    if (text2 != null) {
        editText2.setText(text2);
    }
    if (hint2 != null) {
        editText2.setHint(hint2);
    }
    editText2.setSingleLine(true);

    layout.addView(editText);
    layout.addView(editText2);

    Dialog dialog = new Dialog(context).setView(layout);
    if (negativeListener != null) {
        dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
    }
    if (onDialogEditTextListener != null) {
        dialog
                .setPositiveButton(context.getString(R.string.ok), (dialog1, which)
                        -> onDialogEditTextListener.onClick(
                        Objects.requireNonNull(editText.getText()).toString(), Objects.requireNonNull(editText2.getText()).toString()))
                .setOnDismissListener(dialog1 -> {
                    if (negativeListener != null) {
                        negativeListener.onClick(dialog1, 0);
                    }
                });
    }
    return dialog;
}
 
Example 6
Source File: ViewUtils.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
public static Dialog dialogEditTexts(String text, String text2, String hint, String hint2,
                                     final DialogInterface.OnClickListener negativeListener,
                                     final onDialogEditTextsListener onDialogEditTextListener,
                                     Context context) {
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding);
    layout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText editText = new AppCompatEditText(context);
    editText.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (text != null) {
        editText.append(text);
    }
    if (hint != null) {
        editText.setHint(hint);
    }
    editText.setSingleLine(true);

    final AppCompatEditText editText2 = new AppCompatEditText(context);
    editText2.setLayoutParams(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    if (text2 != null) {
        editText2.setText(text2);
    }
    if (hint2 != null) {
        editText2.setHint(hint2);
    }
    editText2.setSingleLine(true);

    layout.addView(editText);
    layout.addView(editText2);

    Dialog dialog = new Dialog(context).setView(layout);
    if (negativeListener != null) {
        dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
    }
    if (onDialogEditTextListener != null) {
        dialog
                .setPositiveButton(context.getString(R.string.ok), (dialog1, which)
                        -> onDialogEditTextListener.onClick(
                        editText.getText().toString(), editText2.getText().toString()))
                .setOnDismissListener(dialog1 -> {
                    if (negativeListener != null) {
                        negativeListener.onClick(dialog1, 0);
                    }
                });
    }
    return dialog;
}