Java Code Examples for android.text.Selection#selectAll()

The following examples show how to use android.text.Selection#selectAll() . 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: EditText.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Convenience for {@link Selection#selectAll}.
 */
public void selectAll() {
    Selection.selectAll(getText());
}
 
Example 2
Source File: MongolTextView.java    From mongol-library with MIT License 4 votes vote down vote up
public void selectAll() {
    Selection.selectAll(mTextStorage);
}
 
Example 3
Source File: SelectableTextView.java    From AdvancedTextView with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {

    String menuItemTitle = (String) v.getTag();

    // 选中的字符的开始和结束位置
    int start = getSelectionStart();
    int end = getSelectionEnd();
    // 获得选中的字符
    String selected_str;
    if (start < 0 || end < 0 || end <= start) {
        selected_str = "";
    } else
        selected_str = getText().toString().substring(start, end);

    if (menuItemTitle.equals(ActionMenu.DEFAULT_MENU_ITEM_TITLE_SELECT_ALL)) {
        //全选事件
        if (isTextJustify) {
            mStartLine = 0;
            mCurrentLine = getLayout().getLineCount() - 1;
            mStartTextOffset = 0;
            mCurrentTextOffset = getLayout().getLineEnd(mCurrentLine);
            isActionSelectAll = true;
            SelectableTextView.this.invalidate();
        }
        Selection.selectAll(getEditableText());

    } else if (menuItemTitle.equals(ActionMenu.DEFAULT_MENU_ITEM_TITLE_COPY)) {
        // 复制事件
        Utils.copyText(mContext, selected_str);
        Toast.makeText(mContext, "复制成功!", Toast.LENGTH_SHORT).show();
        hideActionMenu();

    } else {
        // 自定义事件
        if (null != mCustomActionMenuCallBack) {
            mCustomActionMenuCallBack.onCustomActionItemClicked(menuItemTitle, selected_str);
        }
        hideActionMenu();
    }
}
 
Example 4
Source File: FMedittext.java    From Android-Music-Player with MIT License 4 votes vote down vote up
/**
 * Convenience for {@link Selection#selectAll}.
 */
public void selectAll() {
    Selection.selectAll(getText());
}
 
Example 5
Source File: EditText.java    From AndroidMaterialValidation with Apache License 2.0 4 votes vote down vote up
/**
 * Convenience for {@link Selection#selectAll}.
 */
public final void selectAll() {
    Selection.selectAll(getText());
}