EditText上的Android键盘下一个按钮问题

Android keyboard next button issue on EditText(EditText上的Android键盘下一个按钮问题)
本文介绍了EditText上的Android键盘下一个按钮问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我遇到了一个问题,我有用户名 &活动中的密码字段,现在当我点击用户名键盘时出现但没有下一个按钮,在这种情况下我无法通过键盘移动到下一个 Edittext 控件,键盘显示输入按钮,如屏幕截图中所附,增加了它的高度,

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,

谁能指导我解决这个问题的方法(在edittext上显示下一个按钮)?

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

我的代码

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键盘下一个按钮问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Prevent enter key on EditText but still show the text as multi-line(防止在 EditText 上输入键,但仍将文本显示为多行)
When the soft keyboard appears, it makes my EditText field lose focus(当软键盘出现时,它使我的 EditText 字段失去焦点)
android how to make text in an edittext exactly fixed lines(android如何在edittext中制作文本完全固定的行)
How to use regular expression in Android(如何在 Android 中使用正则表达式)
Filter list view from edit text(从编辑文本中过滤列表视图)
In android how to show asterisk (*) in place of dots in EditText having inputtype as textPassword?(在android中如何显示星号(*)代替EditText中的点,输入类型为textPassword?)