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("今天天气真好");

  • 相关阅读:
    Dubbo2.0
    Dubbo--RPC框架
    ActiveMQ消息队列
    quartz开源任务调度框架
    webService
    crud最常用
    springBoot第三天
    springmvc--依赖
    springBoot第二天
    pom.xml和settings.xml的下载优先级
  • 原文地址:https://www.cnblogs.com/fxx0129-nn/p/6910794.html
Copyright © 2011-2022 走看看