setText方法 输出string类型的字符串变量

onCreate方法中利用findViewById函数查找TextView对象

mTextView01 =(TextView) findViewById(R.id.myTextView01); 
String str_2 = "welcome android's world";
mTextView01.setText(str_2); //将str_2的值传递给定义的TextView,textview的text值设为str_2

注意 需要先说明textview对象

import android.widget.textview;

之后在activity中说明

private textview mtextview01;

textview的settext支持以下多态构造:

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)

例: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;)

输出为“bcd”

html Tag的转换

<TextView xmlns:android="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"/>


错误:you must supply a layout_width attribute
这个错误出现是由于xml文件内属性未定义;
原文地址:https://www.cnblogs.com/bycainiao/p/5180850.html