2016-09-25 46 views
0

OnButtonClick监听器我想禁用EditText进行编辑,然后再次打开它。禁用后启用Edittext

下面两行我残疾的EditText

editTextWight.setEnabled(false); 
editTextWight.setFocusable(false); 

但是,当我尝试打开它失败。键盘无法打开。

editTextWight.setFocusable(true); 
editTextWight.setFocusableInTouchMode(true); 
editTextWight.setClickable(true); 
editTextWight.setEnabled(true); 

请帮我启用EditText。

回答

0

禁用编辑文本使用

editTextWight.setEnabled(false); 
editTextWight.setInputType(InputType.TYPE_NULL); 
editTextWight.setFocusable(false); 

,使编辑文本使用

editTextWight.setEnabled(true); 
editTextWight.setInputType(InputType.TYPE_CLASS_TEXT); 
editTextWight.setFocusable(true); 
1

你可以试试这个两块为我的项目的代码运行线路:

editTextWight.setFocusable(true); 
editTextWight.setFocusableInTouchMode(true); 

我做这个例如afterTextChanged()被调用,因为我必须先禁用这个EditText然后启用它后来!

所以,只用上面的两个方法调用,而不是所有四个。

祝你好运,让我知道它是否工作!

1

谢谢Eenvincible和sajan。你的回答可以帮助我解决问题。我用这4种方法启用了编辑窗口。

editTextWight.setEnabled(true); 
    editTextWight.setInputType(InputType.TYPE_CLASS_NUMBER); 
    editTextWight.setFocusable(true); 
    editTextWight.setFocusableInTouchMode(true);