本文整理了Java中android.widget.TextView.getEditableText()
方法的一些代码示例,展示了TextView.getEditableText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getEditableText()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getEditableText
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void append_whenSelectionReachesToEnd_shouldExtendSelectionToTheEnd() throws Exception {
textView.setText("12", TextView.BufferType.EDITABLE);
Selection.setSelection(textView.getEditableText(), 0, 2);
textView.append("3");
assertEquals(3, textView.getSelectionEnd());
assertEquals(0, textView.getSelectionStart());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void append_whenSelectionIsAtTheEnd_shouldKeepSelectionAtTheEnd() throws Exception {
textView.setText("1", TextView.BufferType.EDITABLE);
Selection.setSelection(textView.getEditableText(), 0, 0);
textView.append("2");
assertEquals(0, textView.getSelectionEnd());
assertEquals(0, textView.getSelectionStart());
Selection.setSelection(textView.getEditableText(), 2, 2);
textView.append("3");
assertEquals(3, textView.getSelectionEnd());
assertEquals(3, textView.getSelectionStart());
}
代码示例来源:origin: stackoverflow.com
appendLine(tv.getEditableText(), "Line 1 = 40\n", 40);
appendLine(tv.getEditableText(), "Line 2 = 30\n", 30);
appendLine(tv.getEditableText(), "Line 3 = 20\n", 20);
appendLine(tv.getEditableText(), "Line 4 = 10\n", 10);
代码示例来源:origin: stackoverflow.com
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TextView tv = new TextView(this);
tv.setLineSpacing(2, 1); // UPDATE HERE
setContentView(tv);
tv.setText("Lines:\n", BufferType.EDITABLE);
appendLine(tv.getEditableText(), "Line 1 = 40\n", 40);
appendLine(tv.getEditableText(), "Line 2 = 30\n", 30);
appendLine(tv.getEditableText(), "Line 3 = 20\n", 20);
appendLine(tv.getEditableText(), "Line 4 = 10\n", 10);
}
代码示例来源:origin: stackoverflow.com
private final static int MAX_LINE = 50;
private TextView _debugTextView; // Of course, must be filled with your TextView
public void writeTerminal(String data) {
_debugTextView.append(data);
// Erase excessive lines
int excessLineNumber = _debugTextView.getLineCount() - MAX_LINE;
if (excessLineNumber > 0) {
int eolIndex = -1;
CharSequence charSequence = _debugTextView.getText();
for(int i=0; i<excessLineNumber; i++) {
do {
eolIndex++;
} while(eolIndex < charSequence.length() && charSequence.charAt(eolIndex) != '\n');
}
if (eolIndex < charSequence.length()) {
_debugTextView.getEditableText().delete(0, eolIndex+1);
}
else {
_debugTextView.setText("");
}
}
}
代码示例来源:origin: stackoverflow.com
appendLine(tv.getEditableText(), "123456 123 12345678\n", Color.BLACK);
appendLine(tv.getEditableText(), "123456 123 12345678\n", Color.RED);
appendLine(tv.getEditableText(), "123456 123 12345678\n", Color.BLACK);
代码示例来源:origin: com.google.android.apps.common.testing.accessibility.framework/accessibility-test-framework
@Override
public List<AccessibilityViewCheckResult> runCheckOnView(View view) {
List<AccessibilityViewCheckResult> results = new ArrayList<AccessibilityViewCheckResult>(1);
if (view instanceof TextView) {
TextView textView = (TextView) view;
if ((textView.getEditableText() != null)) {
if (!TextUtils.isEmpty(textView.getContentDescription())) {
results.add(new AccessibilityViewCheckResult(this.getClass(),
AccessibilityCheckResultType.ERROR,
"Editable TextView should not have a contentDescription.", textView));
}
} else {
results.add(new AccessibilityViewCheckResult(this.getClass(),
AccessibilityCheckResultType.NOT_RUN, "TextView must be editable", textView));
}
} else {
results.add(new AccessibilityViewCheckResult(this.getClass(),
AccessibilityCheckResultType.NOT_RUN, "View must be a TextView", view));
}
return results;
}
}
代码示例来源:origin: redfish64/TinyTravelTracker
public void onCancel(View target) {
((TextView) findViewById(R.id.enter_password_text)).getEditableText()
.clear();
performCancel();
}
代码示例来源:origin: zeleven/mua
/**
* Perform undo.
*/
public void undo() {
EditItem edit = mEditHistory.getPrevious();
if (edit == null) {
return;
}
Editable text = mTextView.getEditableText();
int start = edit.mmStart;
int end = start + (edit.mmAfter != null ? edit.mmAfter.length() : 0);
mIsUndoOrRedo = true;
text.replace(start, end, edit.mmBefore);
mIsUndoOrRedo = false;
// This will get rid of underlines inserted when editor tries to come
// up with a suggestion.
for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) {
text.removeSpan(o);
}
Selection.setSelection(text, edit.mmBefore == null ? start
: (start + edit.mmBefore.length()));
}
代码示例来源:origin: zeleven/mua
/**
* Perform redo.
*/
public void redo() {
EditItem edit = mEditHistory.getNext();
if (edit == null) {
return;
}
Editable text = mTextView.getEditableText();
int start = edit.mmStart;
int end = start + (edit.mmBefore != null ? edit.mmBefore.length() : 0);
mIsUndoOrRedo = true;
text.replace(start, end, edit.mmAfter);
mIsUndoOrRedo = false;
// This will get rid of underlines inserted when editor tries to come
// up with a suggestion.
for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) {
text.removeSpan(o);
}
Selection.setSelection(text, edit.mmAfter == null ? start
: (start + edit.mmAfter.length()));
}
代码示例来源:origin: geniusgithub/AndroidDialer
@Override
protected void onPostExecute(PhoneNumberFormattingTextWatcher watcher) {
if (watcher == null || isCancelled()) {
return; // May happen if we cancel the task.
}
// Setting a text changed listener is safe even after the view is detached.
mTextView.addTextChangedListener(watcher);
// Forcing formatting the existing phone number
if (mFormatAfterWatcherSet) {
watcher.afterTextChanged(mTextView.getEditableText());
}
}
}
代码示例来源:origin: stackoverflow.com
mEditable = tv.getEditableText();
代码示例来源:origin: jbruchanov/AnUitor
data.put("EditableText", String.valueOf(tv.getEditableText()));
data.put("Error", String.valueOf(tv.getError()));
try {
代码示例来源:origin: stackoverflow.com
Editable text = mTextView.getEditableText();
int start = edit.mmStart;
int end = start + (edit.mmAfter != null ? edit.mmAfter.length() : 0);
Editable text = mTextView.getEditableText();
int start = edit.mmStart;
int end = start + (edit.mmBefore != null ? edit.mmBefore.length() : 0);
代码示例来源:origin: stackoverflow.com
final int off = layout.getOffsetForHorizontal(line, x);
final Editable buffer = widget.getEditableText();
final ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
代码示例来源:origin: nurkiewicz/rxjava-book-examples
@Override public void call(final Subscriber<? super TextViewAfterTextChangeEvent> subscriber) {
verifyMainThread();
final TextWatcher watcher = new TextWatcher() {
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override public void afterTextChanged(Editable s) {
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(TextViewAfterTextChangeEvent.create(view, s));
}
}
};
subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.removeTextChangedListener(watcher);
}
});
view.addTextChangedListener(watcher);
// Emit initial value.
subscriber.onNext(TextViewAfterTextChangeEvent.create(view, view.getEditableText()));
}
}
代码示例来源:origin: stackoverflow.com
if (linesToRemove > 0) {
for (int i = 0; i < linesToRemove; i++) {
Editable text = _textViewOutput.getEditableText();
int lineStart = _textViewOutput.getLayout().getLineStart(0);
int lineEnd = _textViewOutput.getLayout().getLineEnd(0);
代码示例来源:origin: stackoverflow.com
TextView tv = mTextView;
if (tv != null) {
return tv.getEditableText();
内容来源于网络,如有侵权,请联系作者删除!