首页 > 代码库 > Android常用UI组件 - TextView

Android常用UI组件 - TextView

布局文件:main.xml
在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7. <TextView  
  8.     android:layout_width="fill_parent"  
  9.     android:layout_height="wrap_content"  
  10.     android:text="这里是TextView,你可以在这里显示一些文本信息。"  
  11.     />  
  12. </LinearLayout>  

Java源代码文件:MainActivity.java

在CODE上查看代码片派生到我的代码片
  1. package com.rainsong.textviewdemo;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5.   
  6. public class MainActivity extends Activity  
  7. {  
  8.     /** Called when the activity is first created. */  
  9.     @Override  
  10.     public void onCreate(Bundle savedInstanceState)  
  11.     {  
  12.         super.onCreate(savedInstanceState);  
  13.         setContentView(R.layout.main);  
  14.     }  



Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing.
TextView(Context context, AttributeSet attrs, int defStyle)

Android常用UI组件 - TextView