上的EditText Android键盘下一个按钮的问题 [英] Android keyboard next button issue on EditText

查看:246
本文介绍了上的EditText Android键盘下一个按钮的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临一个问题,我有用户名和放大器;在活动密码字段,现在当我点击用户名键盘上出现,但它没有下一个按钮,我无法通过键盘移动到下一个EDITTEXT控制在这种情况下,键盘显示的是回车键作为附加的屏幕快照,增加了它的高度,

任何一个指导我该如何解决这个问题(上显示的EditText下一个按钮)?

任何帮助将是AP preciated

我的code

  txtUserid =(EditText上)findViewById(R.id.txtUserID);
        txtUserPasword =(EditText上)findViewById(R.id.txtPassword);

        txtUserid.setNextFocusDownId(R.id.txtPassword);
        txtUserPasword.setNextFocusDownId(R.id.btnLogin);
 

解决方案

下方的$ C $线c您提供添加此行:

  txtUserid.setOnKeyListener(新OnKeyListener(){

    公共布尔onKey(视图V,INT关键code,KeyEvent的事件){
          //如果事件是对输入按钮的键 - 向下事件
          如果((event.getAction()== KeyEvent.ACTION_DOWN)及&安培;
               (钥匙code == KeyEvent.KEY code_ENTER))
          {
                //执行上的回车键preSS行动
                txtUserid.clearFocus();
                txtUserPasword.requestFocus();
                返回true;
          }
          返回false;
    }
});

txtUserPasword.setOnKeyListener(新OnKeyListener(){

    公共布尔onKey(视图V,INT关键code,KeyEvent的事件){

          如果((event.getAction()== KeyEvent.ACTION_DOWN)及&安培;
                    (钥匙code == KeyEvent.KEY code_ENTER))
          {
                 //执行上的回车键preSS行动
                 在这里密码的正确性 -  //检查用户名
                 返回true;
          }
          返回false;
    }
});
 

I am facing an issue i have username & password fields on activity, now when i click on username keyboard appears but no next button on it and i cannot move to next Edittext control through keyboard in this case, keyboard displays enter button in it as attached in screenshot which increases its height,

any one guide me what is the solution to this problem(to display next button on edittext)?

any help would be appreciated

My Code

txtUserid = (EditText)findViewById(R.id.txtUserID);
        txtUserPasword = (EditText)findViewById(R.id.txtPassword);

        txtUserid.setNextFocusDownId(R.id.txtPassword);
        txtUserPasword.setNextFocusDownId(R.id.btnLogin);

解决方案

add this lines below your lines of code you provided:

txtUserid.setOnKeyListener(new OnKeyListener() {

    public boolean onKey(View v, int keyCode, KeyEvent event) {
          // If the event is a key-down event on the "enter" button
          if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
               (keyCode == KeyEvent.KEYCODE_ENTER))
          {
                // Perform action on Enter key press
                txtUserid.clearFocus();
                txtUserPasword.requestFocus();
                return true;
          }
          return false;
    }
});

txtUserPasword.setOnKeyListener(new OnKeyListener() {

    public boolean onKey(View v, int keyCode, KeyEvent event) {

          if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                    (keyCode == KeyEvent.KEYCODE_ENTER))
          {
                 // Perform action on Enter key press
                 // check for username - password correctness here
                 return true;
          }
          return false;
    }
});

这篇关于上的EditText Android键盘下一个按钮的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆