本文整理了Java中android.widget.TextView.append()
方法的一些代码示例,展示了TextView.append()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.append()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:append
暂无
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onComplete() {
textView.append(" First onComplete");
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " First onComplete");
}
};
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onComplete() {
textView.append(" Second onComplete");
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " Second onComplete");
}
};
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onComplete() {
textView.append(" onComplete");
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onComplete");
}
代码示例来源:origin: googlesamples/android-testing
private void appendEntryToView(String text, long timestamp) {
Date date = new Date(timestamp);
// Add a newline if needed or clear the text view (to get rid of the hint).
if (!mIsHistoryEmpty) {
mHistoryTextView.append("\n");
} else {
mHistoryTextView.setText("");
}
// Add the representation of the new entry to the text view.
mHistoryTextView.append(String.format("%s [%s]", text, mSimpleDateFormatter.format(date)));
mIsHistoryEmpty = false;
}
}
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onError(Throwable e) {
textView.append(" First onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " First onError : " + e.getMessage());
}
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onError(Throwable e) {
textView.append(" Second onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " Second onError : " + e.getMessage());
}
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onError(Throwable e) {
textView.append(" onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onError : " + e.getMessage());
}
代码示例来源:origin: amitshekhariitbhu/RxJava2-Android-Samples
@Override
public void onError(Throwable e) {
textView.append(" Second onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " Second onError : " + e.getMessage());
}
代码示例来源:origin: lingochamp/FileDownloader
private void infoAppend(final String msg, final long start) {
infoTv.append(String.format(" %s: %d\n", msg, System.currentTimeMillis() - start));
scrollView.post(new Runnable() {
@Override
public void run() {
if (scrollView != null) {
scrollView.fullScroll(View.FOCUS_DOWN);
}
}
});
}
代码示例来源:origin: lingochamp/FileDownloader
private void updateDisplay(final CharSequence msg) {
if (downloadMsgTv.getLineCount() > 2500) {
downloadMsgTv.setText("");
}
downloadMsgTv.append(String.format("\n %s", msg));
tipMsgTv.setText(String.format("%d/%d", finalCounts, totalCounts));
if (needAuto2Bottom) {
scrollView.post(scroll2Bottom);
}
}
代码示例来源:origin: stackoverflow.com
TextView TV = (TextView)findViewById(R.id.mytextview01);
Spannable word = new SpannableString("Your message");
word.setSpan(new ForegroundColorSpan(Color.BLUE), 0, word.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TV.setText(word);
Spannable wordTwo = new SpannableString("Your new message");
wordTwo.setSpan(new ForegroundColorSpan(Color.RED), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TV.append(wordTwo);
代码示例来源:origin: robolectric/robolectric
@Test
public void testNoArgAppend() {
textView.setText("a");
textView.append("b");
assertThat(textView.getText().toString()).isEqualTo("ab");
}
代码示例来源:origin: greenrobot/EventBus
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(TestFinishedEvent event) {
Test test = event.test;
String text = "<b>" + test.getDisplayName() + "</b><br/>" + //
test.getPrimaryResultMicros() + " micro seconds<br/>" + //
((int) test.getPrimaryResultRate()) + "/s<br/>";
if (test.getOtherTestResults() != null) {
text += test.getOtherTestResults();
}
text += "<br/>----------------<br/>";
textViewResult.append(Html.fromHtml(text));
if (event.isLastEvent) {
findViewById(R.id.buttonCancel).setVisibility(View.GONE);
findViewById(R.id.textViewTestRunning).setVisibility(View.GONE);
findViewById(R.id.buttonKillProcess).setVisibility(View.VISIBLE);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenAppendingText_ShouldAppendNewTextAfterOldOne() {
textView.setText(INITIAL_TEXT);
textView.append(NEW_TEXT);
assertThat(textView.getText().toString()).isEqualTo(INITIAL_TEXT + NEW_TEXT);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenAppendingText_ShouldFireBeforeTextChangedWithCorrectArguments() {
textView.setText(INITIAL_TEXT);
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.append(NEW_TEXT);
verify(mockTextWatcher).beforeTextChanged(eq(INITIAL_TEXT), eq(0), eq(INITIAL_TEXT.length()), eq(INITIAL_TEXT.length()));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenAppendingText_ShouldFireOnTextChangedWithCorrectArguments() {
textView.setText(INITIAL_TEXT);
TextWatcher mockTextWatcher = mock(TextWatcher.class);
textView.addTextChangedListener(mockTextWatcher);
textView.append(NEW_TEXT);
ArgumentCaptor<SpannableStringBuilder> builderCaptor = ArgumentCaptor.forClass(SpannableStringBuilder.class);
verify(mockTextWatcher).onTextChanged(builderCaptor.capture(), eq(0), eq(INITIAL_TEXT.length()), eq(INITIAL_TEXT.length()));
assertThat(builderCaptor.getValue().toString()).isEqualTo(INITIAL_TEXT + NEW_TEXT);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv=(TextView)findViewById(R.id.text);
for (SmsMessage pdu :
Telephony.Sms.Intents.getMessagesFromIntent(getIntent())) {
tv.append(pdu.getDisplayMessageBody());
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void whenAppendingText_ShouldFireAfterTextChangedWithCorrectArgument() {
textView.setText(INITIAL_TEXT);
MockTextWatcher mockTextWatcher = new MockTextWatcher();
textView.addTextChangedListener(mockTextWatcher);
textView.append(NEW_TEXT);
assertThat(mockTextWatcher.afterTextChangeArgument.toString()).isEqualTo(INITIAL_TEXT + NEW_TEXT);
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!