Android开发之基本组件学习----------EditView组件
来源:互联网 发布:食品各品类零售数据 编辑:程序博客网 时间:2024/04/29 13:47
EditView组件的使用
创建一个EditView组件:在main.xml中创建
<EditText
android:hint="EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="11"
android:singleLine="true"
android:inputType="phone"
android:background="@drawable/shape"
/>
android:hint="XXXX" 表示在文本框的后面出现背景文字
android:maxLength="" 表示文本框可输入的最大长度
android:singleLine="" 表示当前文本框所显示的的文字是否在同一行,属性值为true和false
android:inputType="" 表示当前文本框所输入文字的类型,可以是number phone等
android:background="" 调用一个.xml文件来进行设置文本框,上面的例子表示调用的是shape.xml文件
Shape.xml文件代码如下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充颜色 -->
<solid android:color="#ffffff"/>
<!-- 设置四个角为弧形 -->
<!-- android:radius设置弧形的半径 -->
<corners android:radius="5dip"/>
</shape>
注意:如果想让当前的文本框取消聚焦,可定义两个<EditText>组件,第一个的EditView组件的Layout_hight
和Layout_width的属性值都是“0”即可。
创建一个EditView组件:在main.xml中创建
<EditText
android:hint="EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="11"
android:singleLine="true"
android:inputType="phone"
android:background="@drawable/shape"
/>
android:hint="XXXX" 表示在文本框的后面出现背景文字
android:maxLength="" 表示文本框可输入的最大长度
android:singleLine="" 表示当前文本框所显示的的文字是否在同一行,属性值为true和false
android:inputType="" 表示当前文本框所输入文字的类型,可以是number phone等
android:background="" 调用一个.xml文件来进行设置文本框,上面的例子表示调用的是shape.xml文件
Shape.xml文件代码如下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充颜色 -->
<solid android:color="#ffffff"/>
<!-- 设置四个角为弧形 -->
<!-- android:radius设置弧形的半径 -->
<corners android:radius="5dip"/>
</shape>
注意:如果想让当前的文本框取消聚焦,可定义两个<EditText>组件,第一个的EditView组件的Layout_hight
和Layout_width的属性值都是“0”即可。
- Android开发之基本组件学习----------EditView组件
- Android开发之基本组件学习--------Button组件
- Android初级之组件基础02-EditView
- android editview组件
- Android常用组件-editview
- Android开发之基本组件学习-----------Intent的使用
- Android开发之基本组件学习-----------TextView的使用
- Android开发入门之基本界面组件
- Android基本组件学习
- 学习笔记:Android基本组件之Activity
- 学习笔记:Android基本组件之Service
- Android开发学习之四大组件
- Android开发之四大组件学习
- 【Android开发】基本组件-计时器
- Android知识点之基本组件
- Android开发学习(2)环境搭建及基本组件
- android开发之界面设计---基本组件与布局管理器
- 菜鸟Android学习之路04——基本组件
- Android开发之基本组件学习--------Button组件
- 翻译:Linux的电源管理架构
- sizeof用法
- Debug Android and Linux suspend and resume (中文)
- 重载与覆盖的区别,覆盖与隐藏的区别
- Android开发之基本组件学习----------EditView组件
- .net中多线程的使用
- VBScript如何调用异步调用ajaxpro注册的方法
- 【扫盲帖】Java、JavaScript、JSP、JScript 的区别与联系
- SAP 采购订单抬头屏幕增强
- PHP中控制proc_open的执行时间
- Android开发之基本组件学习-----------Intent的使用
- 我对“人才”的误区
- 系统编程之文件编程file_cp