Andorid中UI控件的详细介绍(四)——EditText
2016-09-12 19:20
513 查看
一、EditText的类结构:
java.lang.Object
↘android.view.View
↘android.widget.TextView
↘android.widget.EditText
由类的结构图可以看出来,EditText是继承与TextView的,所以EditText继承了TextView的所有属性。
![](http://img.blog.csdn.net/20160912190526524)
其中android:password属性不推荐使用,可以用inputType=“textPassword”代替:
1、在程序中设置EditText以明文显示:
setInputType(InputType.TYPE_CLASS_TEXT);
2、在程序中设置EditText以密码显示:
setTnputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
二、android:inputType的可选项:
1、android : inputType = “text” 默认的
2、android : inputType = “textPersonName” 人名
3、android : inputType = “textPassword” 文本密码
4、android : inputType = “numberPassword” 只能输入数字的密码
5、android : inputType = “textEmailAddress” 电邮地址
6、android : inputType = “phone” 电话号码
7、android : inputType = “textPostalAddress” 邮政地址
8、android : inputType = “time” 时间
9、android : inputType = “date” 日期
10、android : inputType = “number”数字
三、EditText常用方法:
1、void setText(int resid);// 传入字符串资源,例如(R.String.xxx)
void setText(char[] text, int start, int len);
void setText(CharSequence text);//CharSequence 是一个接口,可以传入String,StringBuffer,StringBuilder等
2、EditText getText();//根据需要toString()转换为字符串
四、EditText常用属性与方法
java.lang.Object
↘android.view.View
↘android.widget.TextView
↘android.widget.EditText
由类的结构图可以看出来,EditText是继承与TextView的,所以EditText继承了TextView的所有属性。
其中android:password属性不推荐使用,可以用inputType=“textPassword”代替:
1、在程序中设置EditText以明文显示:
setInputType(InputType.TYPE_CLASS_TEXT);
2、在程序中设置EditText以密码显示:
setTnputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
二、android:inputType的可选项:
1、android : inputType = “text” 默认的
2、android : inputType = “textPersonName” 人名
3、android : inputType = “textPassword” 文本密码
4、android : inputType = “numberPassword” 只能输入数字的密码
5、android : inputType = “textEmailAddress” 电邮地址
6、android : inputType = “phone” 电话号码
7、android : inputType = “textPostalAddress” 邮政地址
8、android : inputType = “time” 时间
9、android : inputType = “date” 日期
10、android : inputType = “number”数字
三、EditText常用方法:
1、void setText(int resid);// 传入字符串资源,例如(R.String.xxx)
void setText(char[] text, int start, int len);
void setText(CharSequence text);//CharSequence 是一个接口,可以传入String,StringBuffer,StringBuilder等
2、EditText getText();//根据需要toString()转换为字符串
四、EditText常用属性与方法
相关文章推荐
- Android中UI控件的详细介绍(七)——ImageButton
- Android中UI控件的详细介绍(八)——Android事件处理机制的概述
- Android中UI控件的详细介绍(三)——TextView
- Android中UI控件的详细介绍(六)——ImageView
- 【初学】UI控件学习笔记-UIButton按钮控件详细介绍
- Android中UI控件的详细介绍(一)——Android中UI的总体分类即通用属性
- Android中UI控件的详细介绍(八)——Android事件处理机制的概述
- Android中UI控件的详细介绍(二)—— 非布局控件总览
- Android中UI控件的详细介绍(五)——Button
- cocos2d-x高级UI控件详细介绍
- Winform分页控件使用详细介绍
- marquee 滚动控件的详细介绍
- WinForm停靠控件介绍:WeifenLuo.WinFormsUI.Docking.dll
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- WinForm停靠控件介绍:WeifenLuo.WinFormsUI.Docking.dll
- operamasks-ui2.0 +MVC4.0+EF5.0实战之一 开篇及布局控件介绍
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- DataGridView控件详细介绍
- DataGridView控件详细介绍
- JQuery Smart UI Plugins介绍(2)— 列表控件(Grid)