TextView is the most UI component used in Android, and is generally used when you need to display some information, it cannot be entered, can only be set initially or modified in the program.
Example: Textviewdemo
Operating Effect:
Code Listing:layout file: Main.xml
<?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:layout_width=" fill_parent " android:layout_height=" Wrap_ Content " android:text=" Here is TextView, where you can display some textual information. " /></linearlayout>
Java source code file: Mainactivity.java
Package Com.rainsong.textviewdemo;import Android.app.activity;import Android.os.bundle;public class MainActivity Extends activity{ /** called when the Activity is first created. * /@Override public void OnCreate (Bundle save Dinstancestate) { super.oncreate (savedinstancestate); Setcontentview (R.layout.main); }}
API Knowledge Points
ActivityPublic classActivityextends Contextthemewrapperimplements COMPONENTCALLBACKS2 Keyevent.callback Layoutinflater.factory2 View.oncreatecontextmenulistener Window.callback
known Direct subclassesaccountauthenticatoractivity, Activitygroup, aliasactivity, expandablelistactivity, FragmentActivity, Listactivity, Nativeactivity
known Indirect subclasseslauncheractivity, preferenceactivity, tabactivity
void Setcontentview (int layoutresid)Set the activity content from a layout resource.
TextViewPublic classTextViewextends Viewimplements Viewtreeobserver.onpredrawlistener
known Direct subclassesButton, Checkedtextview, chronometer, DigitalClock, EditText, Textclock
known Indirect subclassesAutocompletetextview, CheckBox, Compoundbutton, Extractedittext, Multiautocompletetextview, RadioButton, Switch, ToggleButton
Class Overviewdisplays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class was configured to not allow editing; See EditText for a subclass this configures the text view for editing.
Public ConstructorsTextView (Context context)TextView (Context context, AttributeSet attrs)TextView (Context context, AttributeSet attrs, int defstyle)
Android Common UI Components-TextView