Android sets different formats for the same string

Source: Internet
Author: User

Use the spannablestringbuilder object to save the string and use its setspan method to set different formats.

Int start = 0;
Txtcontent((textview1_findviewbyid(r.id.txt content_help );
Spannablestringbuilder mspannable = new spannablestringbuilder ();
Mspannable. append ("Image Library browsing \ r \ n"). setspan (New foregroundcolorspan (color. Cyan), 0, mspannable. Length (),
Spannable. span_exclusive_inclusive );
Mspannable. setspan (New underlinespan (), 0, mspannable. Length (), spannable. span_exclusive_exclusive );
Start = mspannable. Length ();
Mspannable. append ("go to the video library and click the next category to be viewed on the left to enter the corresponding library"). setspan
(New foregroundcolorspan (color. White), start, mspannable. Length (), spannable. span_exclusive_inclusive );
Mspannable. append ("\ r \ n ");
Start = mspannable. Length ();
Mspannable. append ("order video \ r \ n"). setspan (New foregroundcolorspan (color. Cyan), start, mspannable. Length (),
Spannable. span_exclusive_inclusive );
Mspannable. setspan (New underlinespan (), start, mspannable. Length (), spannable. span_exclusive_exclusive );
Start = mspannable. Length ();
Mspannable. append ("click a program in the category or directly search for a program, and click the order button to order" + ""). setspan
(New foregroundcolorspan (color. White), start, mspannable. Length (), spannable. span_exclusive_inclusive );
Mspannable. append ("\ r \ n ");
Start = mspannable. Length ();
Mspannable. append ("playing video \ r \ n"). setspan (New foregroundcolorspan (color. Cyan), start, mspannable. Length (),
Spannable. span_exclusive_inclusive );
Mspannable. setspan (New underlinespan (), start, mspannable. Length (), spannable. span_exclusive_exclusive );
Start = mspannable. Length ();
Mspannable. append ("the program that has been ordered and downloaded. In the downloaded management or when you can browse the video library, click play to view the program "). setspan
(New foregroundcolorspan (color. White), start, mspannable. Length (), spannable. span_exclusive_inclusive );
Mspannable. append ("\ r \ n ");
Start = mspannable. Length ();
Mspannable. append ("delete video \ r \ n"). setspan (New foregroundcolorspan (color. Cyan), start, mspannable. Length (),
Spannable. span_exclusive_inclusive );
Mspannable. setspan (New underlinespan (), start, mspannable. Length (), spannable. span_exclusive_exclusive );
Start = mspannable. Length ();
Mspannable. append ("select a Downloaded Program from" Download Management ", click the" delete "icon of the garbage basket, or click" delete all "button to delete"). setspan
(New foregroundcolorspan (color. White), start, mspannable. Length (), spannable. span_exclusive_inclusive );
Mspannable. append ("\ r \ n ");
Start = mspannable. Length ();
Mspannable. append ("download time \ r \ n"). setspan (New foregroundcolorspan (color. Cyan), start, mspannable. Length (),
Spannable. span_exclusive_inclusive );
Mspannable. setspan (New underlinespan (), start, mspannable. Length (), spannable. span_exclusive_exclusive );
Start = mspannable. Length ();
Mspannable. append ("varies depending on the size of the selected program and the download time of the user's bandwidth. "+
"\ R \ n2mb bandwidth, SD movies take 1-2 hours. "). Setspan (New foregroundcolorspan
(Color. White), start, mspannable. Length (), spannable. span_exclusive_inclusive );
Txtcontent. settext (mspannable );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.