码迷,mamicode.com
首页 > 移动开发 > 详细

Android常用UI组件 - TextView

时间:2014-10-25 18:47:17      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:android   textview   

TextView是Android里面用的最多的UI组件,一般使用在需要显示一些信息的时候,其不能输入,只能初始设定或者在程序中修改。

实例:TextViewDemo
运行效果:
bubuko.com,布布扣
代码清单:
布局文件: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

标签:android   textview   

原文地址:http://blog.csdn.net/hantangsongming/article/details/40454795

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!