Java Code Examples for android.support.v7.widget.AppCompatEditText#setSelection()

The following examples show how to use android.support.v7.widget.AppCompatEditText#setSelection() . 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: TodoListActivity.java    From TodoFluxArchitecture with Apache License 2.0 6 votes vote down vote up
private void showEditDialog(TodoItem item) {

        View customView = LayoutInflater.from(this).inflate(R.layout.dialog_todo_edit, null);
        final AppCompatEditText editText = ButterKnife.findById(customView, R.id.inputEditText);
        editText.setText(item.getDescription());
        editText.setSelection(item.getDescription().length());

        materialDialog = new MaterialDialog.Builder(this)
                .customView(customView, false)
                .positiveColorRes(R.color.positive_color)
                .negativeColorRes(R.color.positive_color)
                .positiveText(R.string.action_sure)
                .negativeText(R.string.action_cancel)
                .onPositive((dialog, which) -> {
                    String text = editText.getText().toString();
                    if (!TextUtils.isEmpty(text)) {
                        actionCreator.createItemEditAction(item.getId(), text, item.isCompleted(), item.isStared());
                        dialog.dismiss();
                    }
                })
                .build();


        materialDialog.show();
    }
 
Example 2
Source File: IpInputEditText.java    From v9porn with MIT License 5 votes vote down vote up
/**
 * 聚焦控件,并将光标移至文字后
 *
 * @param appCompatEditText CompatEditText
 */
private void focusEditViewAndMoveSelection(AppCompatEditText appCompatEditText) {
    if (appCompatEditText == null) {
        return;
    }
    appCompatEditText.setFocusable(true);
    appCompatEditText.requestFocus();
    appCompatEditText.setSelection(appCompatEditText.getText().length());

}
 
Example 3
Source File: IpInputEditText.java    From v9porn with MIT License 5 votes vote down vote up
/**
 * 聚焦控件,并将光标移至文字后
 *
 * @param appCompatEditText CompatEditText
 */
private void focusEditViewAndMoveSelection(AppCompatEditText appCompatEditText) {
    if (appCompatEditText == null) {
        return;
    }
    appCompatEditText.setFocusable(true);
    appCompatEditText.requestFocus();
    appCompatEditText.setSelection(appCompatEditText.getText().length());

}
 
Example 4
Source File: IpInputEditText.java    From v9porn with MIT License 4 votes vote down vote up
/**
 * 将光标移到末尾
 **/
private void moveSelectionToLast(AppCompatEditText edittext) {
    int length = edittext.getText().length();
    edittext.setSelection(length);
}
 
Example 5
Source File: IpInputEditText.java    From v9porn with MIT License 4 votes vote down vote up
/**
 * 将光标移到末尾
 **/
private void moveSelectionToLast(AppCompatEditText edittext) {
    int length = edittext.getText().length();
    edittext.setSelection(length);
}