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

The following examples show how to use android.widget.EditText#setHorizontallyScrolling() . 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: PopupActivity.java    From ankihelper with GNU General Public License v3.0 6 votes vote down vote up
private void setupEditNoteDialog() {
        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PopupActivity.this);
        LayoutInflater inflater = PopupActivity.this.getLayoutInflater();
        final View dialogView = inflater.inflate(R.layout.dialog_edit_note, null);
        dialogBuilder.setView(dialogView);

        final EditText edt = (EditText) dialogView.findViewById(R.id.edit_note);
        edt.setHorizontallyScrolling(false);
        edt.setMaxLines(4);
        edt.setText(mNoteEditedByUser);
        edt.setSelection(mNoteEditedByUser.length());
        dialogBuilder.setTitle(R.string.dialog_note);
        //dialogBuilder.setMessage("输入笔记");
        dialogBuilder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                mNoteEditedByUser = edt.getText().toString();
            }
        });
//                        dialogBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
//                            public void onClick(DialogInterface dialog, int whichButton) {
//                                //pass
//                            }
//                        });
        AlertDialog b = dialogBuilder.create();
        b.show();
    }
 
Example 2
Source File: FileChooser.java    From MifareClassicTool with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Ask the user for a file name, create this file and choose it.
 * ({@link #onFileChosen(View)}).
 */
private void onNewFile() {
    final Context cont = this;
    // Ask user for filename.
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setLines(1);
    input.setHorizontallyScrolling(true);
    new AlertDialog.Builder(this)
        .setTitle(R.string.dialog_new_file_title)
        .setMessage(R.string.dialog_new_file)
        .setIcon(android.R.drawable.ic_menu_add)
        .setView(input)
        .setPositiveButton(R.string.action_ok,
                (dialog, whichButton) -> {
                    if (input.getText() != null
                            && !input.getText().toString().equals("")) {
                        File file = new File(mDir.getPath(),
                                input.getText().toString());
                        if (file.exists()) {
                            Toast.makeText(cont,
                                    R.string.info_file_already_exists,
                                    Toast.LENGTH_LONG).show();
                            return;
                        }
                        Intent intent = new Intent();
                        intent.putExtra(EXTRA_CHOSEN_FILE, file.getPath());
                        setResult(Activity.RESULT_OK, intent);
                        finish();
                    } else {
                        // Empty name is not allowed.
                        Toast.makeText(cont, R.string.info_empty_file_name,
                                Toast.LENGTH_LONG).show();
                    }
                })
        .setNegativeButton(R.string.action_cancel,
                (dialog, whichButton) -> {
                    // Do nothing.
                }).show();
}
 
Example 3
Source File: KeyEditor.java    From MifareClassicTool with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if it is a valid key file
 * ({@link #isValidKeyFileErrorToast()}),
 * ask user for a save name and then call
 * {@link Common#checkFileExistenceAndSave(File, String[], boolean,
 * Context, IActivityThatReactsToSave)}
 * @see Common#checkFileExistenceAndSave(File, String[], boolean, Context,
 * IActivityThatReactsToSave)
 * @see #isValidKeyFileErrorToast()
 */
private void onSave() {
    if (!isValidKeyFileErrorToast()) {
        return;
    }
    final File path = Common.getFileFromStorage(Common.HOME_DIR + "/" +
            Common.KEYS_DIR);
    final Context cont = this;
    final IActivityThatReactsToSave activity =
            this;
    // Ask user for filename.
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setLines(1);
    input.setHorizontallyScrolling(true);
    input.setText(mFileName);
    input.setSelection(input.getText().length());
    new AlertDialog.Builder(this)
        .setTitle(R.string.dialog_save_keys_title)
        .setMessage(R.string.dialog_save_keys)
        .setIcon(android.R.drawable.ic_menu_save)
        .setView(input)
        .setPositiveButton(R.string.action_ok,
                (dialog, whichButton) -> {
                    if (input.getText() != null
                            && !input.getText().toString().equals("")) {
                        File file = new File(path.getPath(),
                                input.getText().toString());
                        Common.checkFileExistenceAndSave(file, mLines,
                                false, cont, activity);
                    } else {
                        // Empty name is not allowed.
                        Toast.makeText(cont, R.string.info_empty_file_name,
                                Toast.LENGTH_LONG).show();
                    }
                })
        .setNegativeButton(R.string.action_cancel,
                (dialog, whichButton) -> mCloseAfterSuccessfulSave = false).show();
}
 
Example 4
Source File: DumpEditor.java    From MifareClassicTool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check if the external storage is writable
 * {@link Common#isExternalStorageWritableErrorToast(Context)},
 * ask user for a save name and then call
 * {@link Common#checkFileExistenceAndSave(File, String[], boolean,
 * Context, IActivityThatReactsToSave)}.
 * This is a helper function for {@link #saveDump()}
 * and {@link #saveKeys()}.
 * @param data Data to save.
 * @param fileName Name of the file.
 * @param isDump True if data contains a dump. False if data contains keys.
 * @param titleId Resource ID for the title of the dialog.
 * @param messageId Resource ID for the message of the dialog.
 * @see Common#isExternalStorageWritableErrorToast(Context)
 * @see Common#checkFileExistenceAndSave(File, String[], boolean,
 * Context, IActivityThatReactsToSave)
 */
private void saveFile(final String[] data, final String fileName,
        final boolean isDump, int titleId, int messageId) {
    if (!Common.getPreferences().getBoolean(UseInternalStorage.toString(),
            false) && !Common.isExternalStorageWritableErrorToast(this)) {
        return;
    }
    String targetDir = (isDump) ? Common.DUMPS_DIR : Common.KEYS_DIR;
    final File path = Common.getFileFromStorage(
            Common.HOME_DIR +  "/" + targetDir);
    final Context context = this;
    final IActivityThatReactsToSave activity = this;

    // Ask user for filename.
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setLines(1);
    input.setHorizontallyScrolling(true);
    input.setText(fileName);
    input.setSelection(input.getText().length());
    new AlertDialog.Builder(this)
        .setTitle(titleId)
        .setMessage(messageId)
        .setIcon(android.R.drawable.ic_menu_save)
        .setView(input)
        .setPositiveButton(R.string.action_save,
                (dialog, whichButton) -> {
                    if (input.getText() != null
                            && !input.getText().toString().equals("")) {
                        File file = new File(path.getPath(),
                                input.getText().toString());
                        Common.checkFileExistenceAndSave(file, data,
                                isDump, context, activity);
                        if (isDump) {
                            mDumpName = file.getName();
                        } else {
                            mKeysName = file.getName();
                        }
                    } else {
                        // Empty name is not allowed.
                        Toast.makeText(context, R.string.info_empty_file_name,
                                Toast.LENGTH_LONG).show();
                    }
                })
        .setNegativeButton(R.string.action_cancel,
                (dialog, whichButton) -> mCloseAfterSuccessfulSave = false).show();
    onUpdateColors(null);
}