• Android-TextView文本框Demo


    代码

    package com.lxt008;
    
    import com.lxt008.R;
    
    import android.app.Activity;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class TextViewActivity extends Activity
    {
        /* 声明TextView对象 */
        private TextView textview;
        
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            /* 获得TextView对象 */
            textview = (TextView)this.findViewById(R.id.textview);
            
            String string = "TextView示例,欢迎使用!";
            
            /* 设置文本的颜色 */
            textview.setTextColor(Color.RED);
            /* 设置字体大小 */
            textview.setTextSize(20);
            /* 设置文字背景 */
            textview.setBackgroundColor(Color.BLUE);
            /* 设置TextView显示的文字 */
            textview.setText(string);
        }
    }

    布局文件

    <?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:id="@+id/textview"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
    </LinearLayout>
  • 相关阅读:
    第5章 语句(1)
    第6章 6.2 创建对象
    js考试题目相关
    第6章 6.3 继承
    第6章 面向对象 导论
    第6章 6.1 理解对象
    第5章 语句(2)
    第6章 面向对象 导论(javascript的面向对象)
    第6章 面向对象深入理解
    第3章 补充(图解JavaScript执行环境、作用域、闭包)
  • 原文地址:https://www.cnblogs.com/spadd/p/4189898.html
Copyright © 2020-2023  润新知