1. 设置光标到指定位置
1
2 |
EditText et = (EditText ) findViewById (R. id. etTest ) ;
et. setSelection ( 2 ) ; |
2. 隐藏光标
1
2 3 |
EditText et = (EditText ) findViewById (R. id. etTest ) ;
//设置光标不显示,但不能设置光标颜色 et. setCursorVisible ( false ) ; |
3. 获得焦点时全选文本
1
2 |
EditText et = (EditText ) findViewById (R. id. etTest ) ;
et. setSelectAllOnFocus ( true ) ; |
4. 获取和失去焦点
1
2 3 |
EditText et = (EditText ) findViewById (R. id. etTest ) ;
et. requestFocus ( ) ; //请求获取焦点 et. clearFocus ( ) ; //清除焦点 |
No comments:
Post a Comment