首页 > 代码库 > Android常用UI组件 - TextView
Android常用UI组件 - 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知识点
Activity
public class
Activity
extends ContextThemeWrapper
implements ComponentCallbacks2 KeyEvent.Callback LayoutInflater.Factory2 View.OnCreateContextMenuListener Window.Callback
Known Direct Subclasses
AccountAuthenticatorActivity, ActivityGroup, AliasActivity, ExpandableListActivity, FragmentActivity, ListActivity, NativeActivity
Known Indirect Subclasses
LauncherActivity, PreferenceActivity, TabActivity
void setContentView(int layoutResID)
Set the activity content from a layout resource.
TextView
public class
TextView
extends View
implements ViewTreeObserver.OnPreDrawListener
Known Direct Subclasses
Button, CheckedTextView, Chronometer, DigitalClock, EditText, TextClock
Known Indirect Subclasses
AutoCompleteTextView, CheckBox, CompoundButton, ExtractEditText, MultiAutoCompleteTextView, RadioButton, Switch, ToggleButton
Class Overview
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.
Public Constructors
TextView(Context context)
TextView(Context context, AttributeSet attrs)
TextView(Context context, AttributeSet attrs, int defStyle)
Android常用UI组件 - TextView
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。