2012-03-20 72 views
0

嗨我在我的程序部分禁用了edittext,但后来我想把它重新联机,并且它不接受焦点或文本输入。这里是代码android diasble EditText但无法恢复生命

禁用

 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和微调都是查找,只是editText启动启用,禁用后不会重新启用。

帮助将不胜感激。 谢谢。

+0

这里要禁用微调的点击事件intType.setClickable(假); 。 – 2012-03-20 16:13:11

+0

是'setInputType(NULL)'还是'setFocusable(false)'真的必要? – dldnh 2012-03-20 16:22:08

+0

我确实在其他地方看过他们的说法,说实话我还没有尝试过,但人们谈论过软键盘和跟踪球等问题。所以想要玩起来安全并且全部禁用。不要从主要问题分散注意力,禁用和重新启用更多,那么我真的需要不应该导致我认为的问题? – Purplemonkey 2012-03-20 16:25:24

回答

0

试试这个:

禁用

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(); 
+0

不错,这是一种享受。谢谢。 – Purplemonkey 2012-03-20 16:57:41