我试图在Kotlin
中以编程方式禁用EditText
,但我找不到任何方法.我try 了以下不起作用的代码:
panEditText.focusable = false //Requires API 26 and above.
panEditText.enabled = false //No such method found
如何在Kotlin
编程语言中禁用EditText
?
我试图在Kotlin
中以编程方式禁用EditText
,但我找不到任何方法.我try 了以下不起作用的代码:
panEditText.focusable = false //Requires API 26 and above.
panEditText.enabled = false //No such method found
如何在Kotlin
编程语言中禁用EditText
?
You should use isEnabled
.
Set the enabled state of this view.
panEditText.isEnabled =false
Method Overview个
@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();
}
}