2012-03-20 75 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