<i id='GDNkB'><tr id='GDNkB'><dt id='GDNkB'><q id='GDNkB'><span id='GDNkB'><b id='GDNkB'><form id='GDNkB'><ins id='GDNkB'></ins><ul id='GDNkB'></ul><sub id='GDNkB'></sub></form><legend id='GDNkB'></legend><bdo id='GDNkB'><pre id='GDNkB'><center id='GDNkB'></center></pre></bdo></b><th id='GDNkB'></th></span></q></dt></tr></i><div id='GDNkB'><tfoot id='GDNkB'></tfoot><dl id='GDNkB'><fieldset id='GDNkB'></fieldset></dl></div>

        <small id='GDNkB'></small><noframes id='GDNkB'>

        • <bdo id='GDNkB'></bdo><ul id='GDNkB'></ul>
        <tfoot id='GDNkB'></tfoot>
        <legend id='GDNkB'><style id='GDNkB'><dir id='GDNkB'><q id='GDNkB'></q></dir></style></legend>
      1. 如何收听 EditText?

        时间:2023-05-28
              <bdo id='zsjhv'></bdo><ul id='zsjhv'></ul>

                <tbody id='zsjhv'></tbody>
            • <legend id='zsjhv'><style id='zsjhv'><dir id='zsjhv'><q id='zsjhv'></q></dir></style></legend>
                <tfoot id='zsjhv'></tfoot>

              • <i id='zsjhv'><tr id='zsjhv'><dt id='zsjhv'><q id='zsjhv'><span id='zsjhv'><b id='zsjhv'><form id='zsjhv'><ins id='zsjhv'></ins><ul id='zsjhv'></ul><sub id='zsjhv'></sub></form><legend id='zsjhv'></legend><bdo id='zsjhv'><pre id='zsjhv'><center id='zsjhv'></center></pre></bdo></b><th id='zsjhv'></th></span></q></dt></tr></i><div id='zsjhv'><tfoot id='zsjhv'></tfoot><dl id='zsjhv'><fieldset id='zsjhv'></fieldset></dl></div>

                  <small id='zsjhv'></small><noframes id='zsjhv'>

                1. 本文介绍了如何收听 EditText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 EditText.当用户在更改 EditText 时按下 Enter 键时,我想做点什么.我怎样才能做到这一点?

                  I have a EditText. I wamt tp do something, when the user presses the Enter key while changing EditText. How can I do that?

                  最简单的方法:

                  final EditText edittext = (EditText) findViewById(R.id.edittext);
                  edittext.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 key press
                            Toast.makeText(HelloFormStuff.this, edittext.getText(), Toast.LENGTH_SHORT).show();
                            return true;
                          }
                          return false;
                      }
                  });
                  

                  推荐答案

                  文本观察器示例代码

                  your_edittext.addTextChangedListener(new InputValidator());
                  
                      private class InputValidator implements TextWatcher {
                  
                          public void afterTextChanged(Editable s) {
                  
                          }    
                          public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after) {                
                  
                          }    
                          public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
                  
                          }    
                      }    
                  }
                  

                  这篇关于如何收听 EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何大写Android EditText中的每个字母? 下一篇:RxTextView.textChanges 与 Edittext 上的 setText

                  相关文章

                  1. <small id='kdcVw'></small><noframes id='kdcVw'>

                    <legend id='kdcVw'><style id='kdcVw'><dir id='kdcVw'><q id='kdcVw'></q></dir></style></legend>

                      <bdo id='kdcVw'></bdo><ul id='kdcVw'></ul>
                  2. <i id='kdcVw'><tr id='kdcVw'><dt id='kdcVw'><q id='kdcVw'><span id='kdcVw'><b id='kdcVw'><form id='kdcVw'><ins id='kdcVw'></ins><ul id='kdcVw'></ul><sub id='kdcVw'></sub></form><legend id='kdcVw'></legend><bdo id='kdcVw'><pre id='kdcVw'><center id='kdcVw'></center></pre></bdo></b><th id='kdcVw'></th></span></q></dt></tr></i><div id='kdcVw'><tfoot id='kdcVw'></tfoot><dl id='kdcVw'><fieldset id='kdcVw'></fieldset></dl></div>
                    <tfoot id='kdcVw'></tfoot>