android 身高体重设计,Android开发--身高体重指数(BIM)计算--设计用户界面--指定输入类型(InputType)...

/* (程序头部注释开始)

* 程序的版权和版本声明部分

* Copyright (c) 2011, 烟台大学计算机学院学生

* All rights reserved.

* 文件名称:指定输入类型(InputType)

* 作 者: 雷恒鑫

* 完成日期: 2012 年 08 月 5 日

* 版 本 号: V1.0

* 对任务及求解方法的描述部分

* 输入描述:

* 问题描述:Android1.5版之后添加了软件虚拟键盘的功能,该实验通过把“android:numeric”替换成“android:inputType”让用户再输入数据时,自动弹出软键盘而且直接弹出的是数字软键盘。

* 程序输出:

* 程序头部的注释结束

*/

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="身高(cm)"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:inputType="number"

android:text=""

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="体重(kg)"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:numeric="integer"

android:text=""

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="计算BMI的值"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text=""

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text=""

/>

运行结果:

0818b9ca8b590ca3270a3433284dd417.png

注意:“android:inputType”参数除了替换原有的一些参数之外,还供了更多的参数类型,如果将“android:inputType”的参数设置成“numberDecimal”的话,输入文本框中就可以接受包含小数点的数字,到时候算出来的BMI值就更精确了。

修改后代码如下:

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="身高(cm)"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:inputType="numberDecimal"

android:text=""

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="体重(kg)"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:inputType="numberDecimal"

android:text=""

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="计算BMI的值"

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text=""

/>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text=""

/>

运行结果:

0818b9ca8b590ca3270a3433284dd417.png

经验积累:

1.在Android1.5版之后的新版本中可以直接用“android:inputType”参数来替换“android:password” “android:singleLine” “android:numeric” “android:phoneNumber” “android:capitalize” “android:autoText” “android:editable”这一堆属性。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值