zoukankan      html  css  js  c++  java
  • 基本控件使用(一)

    (一)控件的方式

    1.用XML代码定义

    <TextView

                    android:layout_width="fill_parent"

                    android:layout_height="wrap_content

                    android:text="Hello World"

                    android:textSize="40sp"

    />

    2.用Java代码定义

    TextView tv=new TextView(this);//new一个标签控件

    tv.setText("Hello World");//设置显示的文本

    setContentView(tv);//将该控件设置为窗口的显示内容

    (二)控件的设置

    1.设置控件的ID值

    格式:@+id/ID值,实例:android:id="@+id/tv"

    2.查找文件中的ID值实例化控件

    TextView text=(TextView)super.findViewByID(R.id.mytext);

    3.获取控件中的字符串

    String text=tv.getText().toString();

    4.设置控件中字符串

    text.setText("今天天气真好");

  • 相关阅读:
    c++笔记3
    c++笔记2
    c++笔记1
    零点追踪(零点及量程补偿)
    优秀软件:
    Hart协议
    RL_RTX函数
    keil-rtx
    电源模块选型
    RTX51 Tiny
  • 原文地址:https://www.cnblogs.com/ch123456/p/6837680.html
Copyright © 2011-2022 走看看