展会信息港展会大全

Android EditText 状态切换
来源:互联网   发布日期:2016-01-06 19:15:01   浏览:3907次  

导读:不可编辑状态 EditText android:id=@+id/ed_newPwd android:layout_width=80dp android:layout_height=50dp android:focusable=false/ 可编辑状态 ed_adress.setFocusable(true); ed_adress.requestFocus(); ed_adress.setFocusableInTouchMode(true); 完美...

不可编辑状态

<EditText

android:id="@+id/ed_newPwd"

android:layout_width="80dp"

android:layout_height="50dp"

android:focusable="false"/>

可编辑状态

ed_adress.setFocusable(true);

ed_adress.requestFocus();

ed_adress.setFocusableInTouchMode(true);

完美解决

别忘了关闭键盘进入不可编辑状态的时候

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

//得到InputMethodManager的实例

if (imm.isActive()) {

//如果开启

imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);

//关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的

}

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港