Android常用UI組件 - TextView

來源:互聯網
上載者:User

標籤:android   textview   

TextView是Android裡面用的最多的UI組件,一般使用在需要顯示一些資訊的時候,其不能輸入,只能初始設定或者在程式中修改。
執行個體:TextViewDemo 運行效果:
代碼清單:布局檔案: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="這裡是TextView,你可以在這裡顯示一些文本資訊。"    /></LinearLayout>
Java原始碼檔案: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 savedInstanceState)    {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);    }}


API知識點 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 is configured to not allow editing; see EditText for a subclass that configures the text view for editing.
Public ConstructorsTextView(Context context)TextView(Context context, AttributeSet attrs)TextView(Context context, AttributeSet attrs, int defStyle)

Android常用UI組件 - TextView

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.