android Diastable EditText但无法恢复生命
嗨,我在我的程序中禁用了一个edittext,但后来我想让它重新上线,它不接受焦点或文本输入。这是密码 禁用android Diastable EditText但无法恢复生命,android,android-edittext,Android,Android Edittext,嗨,我在我的程序中禁用了一个edittext,但后来我想让它重新上线,它不接受焦点或文本输入。这是密码 禁用 intTextValue.setEnabled(false); intTextValue.setInputType(InputType.TYPE_NULL); intTextValue.setFocusable(false); intSeek.setEnabled(false); intType.setCli
intTextValue.setEnabled(false);
intTextValue.setInputType(InputType.TYPE_NULL);
intTextValue.setFocusable(false);
intSeek.setEnabled(false);
intType.setClickable(false);
intTextValue.setEnabled(true);
intTextValue.setInputType(InputType.TYPE_CLASS_NUMBER);
intTextValue.setFocusable(true);
intSeek.setEnabled(true);
intType.setClickable(true);
启用
intTextValue.setEnabled(false);
intTextValue.setInputType(InputType.TYPE_NULL);
intTextValue.setFocusable(false);
intSeek.setEnabled(false);
intType.setClickable(false);
intTextValue.setEnabled(true);
intTextValue.setInputType(InputType.TYPE_CLASS_NUMBER);
intTextValue.setFocusable(true);
intSeek.setEnabled(true);
intType.setClickable(true);
你会注意到3个变量名,其中intTextValue是EditText,intSeek是一个搜索栏,intType是一个微调器,seekbar和微调器都是find,只是EditText开始启用,禁用后将无法重新启用
非常感谢您的帮助。
谢谢。试试这个:
禁用:
EditText edt=(EditText)findViewById(R.id.editboxtxt);
edt.setEnabled(false);
edt.setInputType(InputType.TYPE_NULL);
edt.setFocusableInTouchMode(false);
edt.clearFocus();
EditText edt=(EditText)findViewById(R.id.editboxtxt);
edt.setEnabled(true);
edt.setInputType(InputType.TYPE_CLASS_NUMBER);
edt.setFocusableInTouchMode(true);
edt.requestFocus();
启用:
EditText edt=(EditText)findViewById(R.id.editboxtxt);
edt.setEnabled(false);
edt.setInputType(InputType.TYPE_NULL);
edt.setFocusableInTouchMode(false);
edt.clearFocus();
EditText edt=(EditText)findViewById(R.id.editboxtxt);
edt.setEnabled(true);
edt.setInputType(InputType.TYPE_CLASS_NUMBER);
edt.setFocusableInTouchMode(true);
edt.requestFocus();
在这里,您将禁用微调器的单击事件intType.setClickable(false);。
setInputType(NULL)
和setFocusable(false)
真的有必要吗?我确实在别处读到过,说实话,我没有尝试过,但人们谈到软键盘和轨迹球等的问题。。所以我想稳妥行事,把所有的东西都关掉。不过,为了不分散我对主要问题的注意力,禁用和重新启用超出我真正需要的功能应该不会导致我认为的问题?@Purplemonkey:尝试使用这个setFocusableOnTouch()
而不是setFocusableOnTouch()
hi imrankhan,这会导致我的错误”方法setFocusableOnTouch(布尔值)未为类型EditText定义。不过,我确实使用了Eclipse帮助文本,并找到了setFocusableInTouchMode(布尔值),这很有效!!谢谢你。这是排在倒数第二位的bug,还有一个:)另外,你应该把答案添加到主要回复中,我会帮你打勾。