我使用的IDE是Android Studio 2.1,虽然使用Eclipse也可以进行Android的开发,但是网上的大神大都推荐Android Studio,愿意了解的朋友可以参考知乎上关于Android Studio 和 Eclipse的讨论(网页链接:https://www.zhihu.com/question/21534929)。

  今天是正式学习Android开发的第一课,我从一些基本的接口组件的使用开始讲解,文中涉及到的一些接口组件我不会详细的去介绍,具体的介绍可以在网上搜索一下,这样也是为了避免语言的琐碎,提高学习效率。

1.TextView接口组件

    范例:<TextView android:id="@+id/txtRsult"

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:text="程序运行结果"

        />

  以上程序代码的功能是增加一个名为txtRsult的TextView组件,该组件的功能是显示信息,用户无法编辑其中的文字。它的宽度设置为fill_parent,也就是填满它所在的外框,高度设置为wrap_content,也就是由文字的高度来决定,组件中会显示“程序运行结果”这个字符串。除了上面所用到属性,还有很多其他的属性,可以自行在网上搜索一下。

2.EditText接口组件

    范例:<EditText android:id="@+id/edtSex"

             android:layout_width="fill_parent"

                 android:layout_height="wrap_content"

             android:inputType="text"

             android:text=""

        />

  以上程序代码的功能是增加一个名为edtSex的EditText组件,该组件的功能是输入一段文件,再让程序读取该字符串。其中我重点介绍一下android:inputType属性,它是用来限制这个组件可以接受的字符类型,text代表任何字符都可以被接受,如果设置成number则只能输入0~9的数字字符。

3.Button接口组件

    范例:<Button android:id="@+id/btnDoSug"

               android:layout_width="fill_parent"

                   android:layout_height="wrap_content"

            android:text="运行"

        />

  接下来我们将上面所学习的三个接口组件进行整合,程序代码如下:

       <?xml version="1.0" encoding="utf-8"?>

       <LinearLayout

             android:orientation="vertical"

               android:layout_width="fill_parent"

                   android:layout_height="wrap_content" 

          >

        <TextView android:id="@+id/txtRsult"

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:text="性别"

          />

         <EditText android:id="@+id/edtSex"

             android:layout_width="fill_parent"

                 android:layout_height="wrap_content"

             android:inputType="text"

             android:text=""

          />

          <TextView android:id="@+id/txtRsult"

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:text="年龄"

          />   

          <EditText android:id="@+id/edtSex"

             android:layout_width="fill_parent"

                 android:layout_height="wrap_content"

             android:inputType="text"

             android:text=""

          /> 

          <Button android:id="@+id/btnDoSug"

               android:layout_width="fill_parent"

                   android:layout_height="wrap_content"

            android:text="健康建议"

              />   

          <TextView android:id="@+id/txtRsult"

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:text="结果"

          /> 

         <LinearLayout/>

  特别说明一下,<LinearLayout>卷标是指定接口组件采线性顺序排列。它是一种接口组件的编排模式。

  

Android入门(三):使用TextView、EditText 和Button接口组件的更多相关文章

  1. 【Android 应用开发】Android UI 设计之 TextView EditText 组件属性方法最详细解析

    . 作者 :万境绝尘  转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/18964835 . TextView 相关类的继承结构 ...

  2. Android UI 设计之 TextView EditText 组件属性方法最详细解析

    . 作者 :万境绝尘  转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/18964835 . TextView 相关类的继承结构 ...

  3. Android入门(三)Activity-生命周期与启动模式

    原文链接:http://www.orlion.ga/432/ 一.活动的生命周期 1.返回栈 Android中的活动是可以重叠的,我们每启动一个新的活动,就会覆盖在原活动之上,然后点击Back键会销毁 ...

  4. Android入门笔记(一)

    第一部分,Android开发环境的搭建 1.去http://www.oracle.com/technetwork/java/javase/downloads/index.html下载最新版本jdk并安 ...

  5. android入门系列- TextView EditText Button ImageView 的简单应用

    第一篇原创,其实自己就是一菜鸟,简单分享点基本知识吧.希望能有所帮助吧. TextView EditText Button ImageView 这几个控件可能是Android开发中最常用.最基本的几个 ...

  6. Android开发8:UI组件TextView,EditText,Button

    版本:Android4.3 API18 学习整理:liuxinming TextView 概述 TextView直接继承了View(EditText.Button两个UI组件类的父类) TextVie ...

  7. Android入门:绑定本地服务

    一.绑定服务介绍   前面文章中讲过一般的通过startService开启的服务,当访问者关闭时,服务仍然存在: 但是如果存在这样一种情况:访问者需要与服务进行通信,则我们需要将访问者与服务进行绑定: ...

  8. 【详细】Android入门到放弃篇-YES OR NO-》各种UI组件,布局管理器,单元Activity

    问:达叔,你放弃了吗? 答:不,放弃是不可能的,丢了Android,你会心疼吗?如果别人把你丢掉,你是痛苦呢?还是痛苦呢?~ 引导语 有人说,爱上一个人是痛苦的,有人说,喜欢一个人是幸福的. 人与人之 ...

  9. Android入门(四):链接接口组件和程序代码

    编写好layout中的接口组件之后,下一步就是编写控制接口组件的程序代码.上一章,我们使用了三种接口组件,在使用者输入性别和年龄之后点击“健康建议按钮”,程序会读取用户所填入的性别和年龄,然后显示判断 ...

随机推荐

  1. live555库中的testH264VideoStreamer实例

    1.h264文件的推送 testH264VideoStreamer.cpp文件的开头就定义了 char const* inputFileName = "test.264"; 后面接 ...

  2. js实现文本框中内容的放大显示

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  3. GDI+ 笔记

    1.GDI+模板 #include<windows.h> #include<GdiPlus.h> #include <time.h> #include <ma ...

  4. ThinkPHP之OAuth2.0环境搭建

    几个比较好的超链接 1.http://www.tuicool.com/articles/u6beUju 2.http://leyteris.iteye.com/blog/1483403

  5. linux磁盘分区模式

    linux磁盘分区模式 模式一:MBR 1)主分区不超过四个 2)单个分区容量最大2TB 模式二:GPT 1)主分区个数"几乎"没有限制(原因:在GPT的分区表中最多可以支持128 ...

  6. 马化腾称春节前推出微信小程序

    腾讯马化腾在第二届深商大会“互联与时代”论坛上透露,会在2017年春节前推出微信小程序.在谈到“互联网+”.开放生态等话题时,马化腾表示,腾讯从过去5年来,从封闭的环境变成一个开放的环境,变成一个真正 ...

  7. Alpha版本十天冲刺——Day 10

    站立式会议 最后一天,很高兴我们做出了跟预期差不多的版本,实现了基本功能,虽然还有一些bug,但是下一阶段我们会继续加油! 会议总结 队员 今天完成 遇到的问题 感想 鲍亮 功能细节更改 我的手机运行 ...

  8. JVM相关参数的采集

    1.以-jar方式启动jar包: java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=40100 ...

  9. Qml 写的弹出层控件

    QML弹出窗口组件,灯箱效果.动画效果,可拖拽 核心思路:一个mask层,一个最顶层,都用rectangle,禁止事件穿透 使用 Popup { id: popup width: 200; heigh ...

  10. Linq查询表达式

    目录 1. 概述 2. from子句 3. where子句 4. select子句 5. group子句 6. into子句 7. 排序子句 8. let子句 9. join子句 10. 小结 1. ...