您的位置:首页 > 产品设计 > UI/UE

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的所有属性。



其中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常用属性与方法

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ui 控件 edittext