返回键或删除4.4和5.0不工作软键盘的按键? [英] Back key or Delete key of Soft Keyboard not working in 4.4 and 5.0?
问题描述
我面临的返回键或者这是不是在4.4和5.0.1设备工作del键的问题?
当我preSS以下方法softkeyboard的返回键不调用。
I am facing the issue of back key or del key which is not working in 4.4 and 5.0.1 devices ? When I press the back key of softkeyboard below method is not calling.
Username.setOnKeyListener(controller);
Password.setOnKeyListener(controller);
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.KEYCODE_DEL){
getActivity().setDisableLoginButton();
}
return false;
}
任何人都建议我应该怎么办?
我禁用按钮,如果有一个在用户名和放大器没有输入;密码。
请,建议我也建议我其他的解决方案,如果你有。
Anyone suggest me what should I do ? I am disabling the button if there's no input in username & password. Please, suggest me also suggest me other solutions if you have.
推荐答案
因为我发现在这里
https://developer.android.com/training/keyboard-input/commands.html
这是不可能获得软键盘按键事件
It is not possible to get Soft Keyboard Key Events
所以,你应该用 TextWatcher
为编辑文本和获取可用char和删除字符。
So you should use TextWatcher
for edit text and get available char and deleted char.
yourTextView.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
if(yourTextView.getText().toString().length()<=0){
//disabled button here
//It means your edittext is empty...
}
// TODO Auto-generated method stub
}
});
这篇关于返回键或删除4.4和5.0不工作软键盘的按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!