本文整理汇总了Java中android.widget.TextView.append方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.append方法的具体用法?Java TextView.append怎么用?Java TextView.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dealUnderLinesData
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 解析link
*
* @param tv_content
* @param context
*/
private static void dealUnderLinesData(TextView tv_content, Context context) {
CharSequence charSequence = tv_content.getText();
if (charSequence instanceof Spannable) {
tv_content.setText("");
Spannable s = EmojiDisplay.spannableFilter(tv_content.getContext(),
new SpannableStringBuilder(charSequence),
charSequence,
EmoticonsKeyboardUtils.getFontHeight(tv_content));
URLSpan[] spans = s.getSpans(0, s.length(), URLSpan.class);
for (URLSpan span : spans) {
int start = s.getSpanStart(span);
int end = s.getSpanEnd(span);
String clickText = s.subSequence(start, end).toString();
URLSpanNoUnderline urlSpanNoUnderline = new URLSpanNoUnderline(context, span.getURL(), clickText);
s.setSpan(urlSpanNoUnderline, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
tv_content.append(s);
}
}
示例2: onViewCreated
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final TextView logText = (TextView) view.findViewById(R.id.logtext);
IntentFilter statusIntentFilter = new IntentFilter(ServiceUtils.ACTION_LOGBROADCAST);
BroadcastReceiver statusReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra(ServiceUtils.EXTENDED_DATA_LOG)) {
logText.append("\n");
logText.append(intent.getStringExtra(ServiceUtils.EXTENDED_DATA_LOG));
Log.d("received", intent.getStringExtra(ServiceUtils.EXTENDED_DATA_LOG));
}
}
};
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(statusReceiver, statusIntentFilter);
}
示例3: onPostExecute
import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected final void onPostExecute(Object arg) {
TextView textView = textViewRef.get();
if (textView != null) {
for (CharSequence content : newContents) {
textView.append(content);
}
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
HistoryManager historyManager = historyManagerRef.get();
if (historyManager != null) {
for (String[] text : newHistories) {
historyManager.addHistoryItemDetails(text[0], text[1]);
}
}
}
示例4: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// COMPLETED (3) Use findViewById to get a reference to the TextView from the layout
mToysListTextView = (TextView) findViewById(R.id.tv_toy_names);
// COMPLETED (4) Use the static ToyBox.getToyNames method and store the names in a String array
String toyNames[] = ToyBox.getToyNames();
// COMPLETED (5) Loop through each toy and append the name to the TextView (add \n for spacing)
for(String toyName:toyNames) {
mToysListTextView.append(toyName + "\n\n\n");
}
}
示例5: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.receive_share);
Button sendButton = (Button)findViewById(R.id.send_to_service);
final Uri uri = getShareUri(getIntent());
if (uri != null) {
sendButton.setEnabled(true);
} else {
sendButton.setEnabled(false);
}
TextView content = (TextView)findViewById(R.id.receive_share_data);
content.append(buildShareInfo(getContentResolver(), getIntent()));
// Watch for button clicks.
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ReceiveShare.this, ReceiveShareService.class);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
ClipData clip = ClipData.newUri(getContentResolver(), "Something", uri);
intent.setClipData(clip);
startService(intent);
finish();
}
});
}
示例6: into
import android.widget.TextView; //导入方法依赖的package包/类
public void into(@NonNull final TextView textView) {
checkNotNull(textView, "textView == null");
for (final Spannable spannable : spannables) {
textView.append(spannable);
}
}
示例7: line
import android.widget.TextView; //导入方法依赖的package包/类
void line (TextView tv)
{
String temp;
switch (storageType) {
case 0: temp = "undefined"; break;
case 1: temp = "Fixed ROM"; break;
case 2: temp = "Removable ROM"; break;
case 3: temp = "Fixed RAM"; break;
case 4: temp = "Removable RAM"; break;
default:
temp = "Reserved-0x" + Integer.toHexString (storageType);
}
tv.append ("Storage Type: " + temp +" \n");
}
示例8: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_range_layout);
TextView textView = (TextView) findViewById(R.id.text_name);
textView.setText("D");
findViewById(R.id.btn_start_activity).setVisibility(View.GONE);
findViewById(R.id.btn_finish_range_by_class).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_range_begin_router_path1).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_range_begin_router_path2).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_range_begin_router_path3).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_start_to).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_start_to_by_router_path).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_top_activity).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_activity_by_class).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_activity_by_router_path).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_activity).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_activity_except_activity_class).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_activity_except_router_path).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_activity_except_by_list).setVisibility(View.VISIBLE);
findViewById(R.id.btn_finish_all_activity_by_list).setVisibility(View.VISIBLE);
int count = RouterActivityManager.get().getActivityCount();
textView.append("\n\nactivity count:");
textView.append("" + count);
}
示例9: onPostExecute
import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected final void onPostExecute(Object arg) {
TextView textView = textViewRef.get();
if (textView != null) {
for (CharSequence content : newContents) {
textView.append(content);
}
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
示例10: createNoticeView
import android.widget.TextView; //导入方法依赖的package包/类
private TextView createNoticeView(BannerBean content) {
TextView view = new TextView(mContext);
view.setText(content.getTitle());
view.append("\n");
view.append(content.getTitle2());
view.setTextColor(mContext.getResources().getColor(R.color.color_text));
view.setGravity(Gravity.CENTER_VERTICAL);
return view;
}
示例11: span
import android.widget.TextView; //导入方法依赖的package包/类
public static void span(String text, TextView textView) {
SpannableString spanText = new SpannableString(text);
spanText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, text.length(), 0);
spanText.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), 0);
textView.setText("");
textView.append(spanText);
}
示例12: parseTextContent
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 解析文本中的图片
*/
private void parseTextContent(TextView textView, String content) {
// TODO: 2017/7/11 0011 后续可以找到图片后,显示在列表item上
textView.setText("");
Pattern p = Pattern.compile(EditNoteConstans.imageTabBefore+"([^<]*)"+EditNoteConstans.imageTabAfter);
Matcher m = p.matcher(content);
int tempIndex = 0;
List<String> textList=new ArrayList<>();
while (m.find()) {
// 匹配到的数据中,第一个括号的中的内容(这里只有一个括号)
String temp = m.group(1);
// 查找图片标签的位置
int index = content.indexOf(EditNoteConstans.imageTabBefore, tempIndex);
// 将本次开始位置到图片标签间的图片储存起来
String text = content.substring(tempIndex, index);
textList.add(text);
// 将查询起始位置升级
int flagLength=EditNoteConstans.imageTabBefore.length()+EditNoteConstans.imageTabAfter.length();
tempIndex = index + flagLength + temp.length();
}
if(textList.size()!=0){
for (int i=0;i<textList.size();i++){
textView.append(textList.get(i));
textView.append("[图片]");
}
// 将最后一个图片标签后面所有的文字添加
textView.append(content.substring(tempIndex));
}else{
textView.setText(content);
}
}
示例13: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* Using findViewById, we get a reference to our TextView from xml. This allows us to
* do things like set the text of the TextView.
*/
mToysListTextView = (TextView) findViewById(R.id.tv_toy_names);
/*
* This String array contains names of classic toys. After all, these are toy apps. We
* wanted to create a way to break concepts down into smaller pieces that we thought might
* be a little easier to understand. In each lesson, we'll demonstrate new concepts using a
* toy app (no, sadly every one won't have ACTUAL toys in it) and then we'll guide you
* through adding the functionality that you've just learned by having you use those
* concepts in Sunshine! Let us know what you think! We're really excited to have you
* taking this course.
*/
String[] toyNames = ToyBox.getToyNames();
/*
* Iterate through the array and append the Strings to the TextView. The reason why we add
* the "\n\n\n" after the String is to give visual separation between each String in the
* TextView. Later, we'll learn about a better way to display lists of data.
*/
for (String toyName : toyNames) {
mToysListTextView.append(toyName + "\n\n\n");
}
}
示例14: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
/**
* Called when the activity is first created. This is where you should do all of your normal
* static set up: create views, bind data to lists, etc.
* <p>
* Always followed by onStart().
*
* @param savedInstanceState The Activity's previously frozen state, if there was one.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mLifecycleDisplay = (TextView) findViewById(R.id.tv_lifecycle_events_display);
/*
* If savedInstanceState is not null, that means our Activity is not being started for the
* first time. Even if the savedInstanceState is not null, it is smart to check if the
* bundle contains the key we are looking for. In our case, the key we are looking for maps
* to the contents of the TextView that displays our list of callbacks. If the bundle
* contains that key, we set the contents of the TextView accordingly.
*/
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(LIFECYCLE_CALLBACKS_TEXT_KEY)) {
String allPreviousLifecycleCallbacks = savedInstanceState
.getString(LIFECYCLE_CALLBACKS_TEXT_KEY);
mLifecycleDisplay.setText(allPreviousLifecycleCallbacks);
}
}
// COMPLETED (4) Iterate backwards through mLifecycleCallbacks, appending each String and a newline to mLifecycleDisplay
for (int i = mLifecycleCallbacks.size() - 1; i >= 0; i--) {
mLifecycleDisplay.append(mLifecycleCallbacks.get(i) + "\n");
}
// COMPLETED (5) Clear mLifecycleCallbacks after iterating through it
mLifecycleCallbacks.clear();
logAndAppend(ON_CREATE);
}
示例15: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forecast);
// COMPLETED (2) Use findViewById to get a reference to the weather display TextView
mWeatherTextView = (TextView) findViewById(R.id.tv_weather_data);
// COMPLETED (3) Create an array of Strings that contain fake weather data
String[] dummyWeatherData = {
"Today, May 17 - Clear - 17°C / 15°C",
"Tomorrow - Cloudy - 19°C / 15°C",
"Thursday - Rainy- 30°C / 11°C",
"Friday - Thunderstorms - 21°C / 9°C",
"Saturday - Thunderstorms - 16°C / 7°C",
"Sunday - Rainy - 16°C / 8°C",
"Monday - Partly Cloudy - 15°C / 10°C",
"Tue, May 24 - Meatballs - 16°C / 18°C",
"Wed, May 25 - Cloudy - 19°C / 15°C",
"Thu, May 26 - Stormy - 30°C / 11°C",
"Fri, May 27 - Hurricane - 21°C / 9°C",
"Sat, May 28 - Meteors - 16°C / 7°C",
"Sun, May 29 - Apocalypse - 16°C / 8°C",
"Mon, May 30 - Post Apocalypse - 15°C / 10°C",
};
// COMPLETED (4) Append each String from the fake weather data array to the TextView
for (String dummyWeatherDay : dummyWeatherData) {
mWeatherTextView.append(dummyWeatherDay + "\n\n\n");
}
}