<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?

        How do listen EditText?(如何收听 EditText?)
              <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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)

                      <tbody id='kdcVw'></tbody>

                    • <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>
                      • <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>