安卓显示文本框的使用
在安卓中只要想显示不同的文本,就要使用此控件。
在项目src文件夹下添加Activity,添加一个TextViewActivity。


package
cn.Kurodo;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class TextViewActivity extends Activity {
private TextView txtView;
public TextViewActivity()
{}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super .onCreate(savedInstanceState);
setContentView(R.layout.textview);
txtView = (TextView)findViewById(R.id.ibelive);
// 设置TextView的值
txtView.setText(getString(R.string.belive));
Log.v( " ibelive " ,String.valueOf(txtView.getText()));
}
}
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class TextViewActivity extends Activity {
private TextView txtView;
public TextViewActivity()
{}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super .onCreate(savedInstanceState);
setContentView(R.layout.textview);
txtView = (TextView)findViewById(R.id.ibelive);
// 设置TextView的值
txtView.setText(getString(R.string.belive));
Log.v( " ibelive " ,String.valueOf(txtView.getText()));
}
}
TextView的布局文件


<?
xml version="1.0" encoding="utf-8"
?>
< LinearLayout
xmlns:android ="http://schemas.android.com/apk/res/android"
android:orientation ="vertical"
android:layout_width ="fill_parent"
android:layout_height ="fill_parent" >
< TextView android:id ="@+id/ibelive"
android:layout_width ="fill_parent"
android:layout_height ="wrap_content"
android:text ="@string/belive" />
</ LinearLayout >
< LinearLayout
xmlns:android ="http://schemas.android.com/apk/res/android"
android:orientation ="vertical"
android:layout_width ="fill_parent"
android:layout_height ="fill_parent" >
< TextView android:id ="@+id/ibelive"
android:layout_width ="fill_parent"
android:layout_height ="wrap_content"
android:text ="@string/belive" />
</ LinearLayout >
运行效果