android.widget.TextView#getSelectionEnd ( )源码实例Demo

下面列出了android.widget.TextView#getSelectionEnd ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/** {@hide} */
@Override
protected boolean leftWord(TextView widget, Spannable buffer) {
    final int selectionEnd = widget.getSelectionEnd();
    final WordIterator wordIterator = widget.getWordIterator();
    wordIterator.setCharSequence(buffer, selectionEnd, selectionEnd);
    return Selection.moveToPreceding(buffer, wordIterator, isSelecting(buffer));
}
 
/** {@hide} */
@Override
protected boolean rightWord(TextView widget, Spannable buffer) {
    final int selectionEnd = widget.getSelectionEnd();
    final WordIterator wordIterator = widget.getWordIterator();
    wordIterator.setCharSequence(buffer, selectionEnd, selectionEnd);
    return Selection.moveToFollowing(buffer, wordIterator, isSelecting(buffer));
}
 
源代码3 项目: android   文件: LogsActivity.java
@Override
protected void onPostExecute(String s) {
    TextView content = findViewById(R.id.log_content);
    if (content.getSelectionStart() == content.getSelectionEnd()) {
        content.setText(s);
    }
    super.onPostExecute(s);
}
 
源代码4 项目: timecat   文件: CopyActivity.java
private String getSelectedTextViewText(TextView textView) {
    if (textView == null) {
        return getSelectedText();
    } else {
        CharSequence text = textView.getText();
        if (textView.getSelectionStart() == textView.getSelectionEnd()) {
            return text.toString();
        } else {
            CharSequence selected = text.subSequence(textView.getSelectionStart(), textView.getSelectionEnd());
            return selected != null ? selected.toString() : text.toString();
        }
    }
}
 
源代码5 项目: aedict   文件: CopyActivity.java
public static String getSelection(TextView tv) {
	final int e=tv.getSelectionEnd();
	final int s=tv.getSelectionStart();
	if (e < 0 || s < 0 || s == e) {
		return tv.getText().toString();
	}
	return tv.getText().toString().substring(s, e);
}
 
 方法所在类
 同类方法