我试图以EditText编程方式禁用,Kotlin但我找不到任何方法.我尝试下面没有工作的代码:
panEditText.focusable = false //Requires API 26 and above.
panEditText.enabled = false //No such method found
Run Code Online (Sandbox Code Playgroud)
如何EditText在Kotlin编程语言中禁用?
Int*_*iya 11
你应该用isEnabled.
设置此视图的启用状态.
panEditText.isEnabled =false
Run Code Online (Sandbox Code Playgroud)
方法概述
@android.view.RemotableViewMethod
@Override
public void setEnabled(boolean enabled) {
if (enabled == isEnabled()) {
return;
}
if (!enabled) {
// Hide the soft input if the currently active TextView is disabled
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
}
super.setEnabled(enabled);
if (enabled) {
// Make sure IME is updated with current editor info.
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) imm.restartInput(this);
}
// Will change text color
if (mEditor != null) {
mEditor.invalidateTextDisplayList();
mEditor.prepareCursorControllers();
// start or stop the cursor blinking as appropriate
mEditor.makeBlink();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2329 次 |
| 最近记录: |