SetText method Output string variable of type string

Source: Internet
Author: User

Finding TextView objects using the Findviewbyid function in the OnCreate method

mTextView01 = (TextView) Findviewbyid (r.id. MYTEXTVIEW01);
String str_2 = "Welcome Android ' s World";
Mtextview01.settext (str_2); The text value of the Str_2 value passed to the defined Textview,textview is set to Str_2

Note The TextView object needs to be described first

Import Android.widget.textview;

Then explain it in the activity

Private TextView mtextview01;

The TextView SetText supports the following polymorphic constructs:

Public final void SetText (charsequence text)

Publice final void settext (int resid)

Publice viod settext (charsequence text,textview.buffertype type)

Publice final void settext (int resid,textview.buffertype type)

Publice final Viod settext (char[] text, int start, int len)

Example: char char_1[] = new CHAR[5];

Char_1[0] = ' a ';

Char_1[1] = ' B ';

CHAR_1[2] = ' C ';

CHAR_1[3] = ' d ';

CHAR_1[4] = ' e ';

Mtextview01.settext (char_1,1,3;)

Output as "BCD"

Conversion of HTML tags

<TextViewxmlnsAndroid="Http://schemas.android.com/apk/res/android"
Android: layout_width="Wrap_content"
android: layout_height="Wrap_content"
android: autolink="All"
android: text="Please button:http//www.baidu.com"/>

Error: You must supply a layout_width attribute
This error occurs because the attribute in the XML file is undefined;

SetText method Output string variable of type string

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.