• <bdo id='JXS11'></bdo><ul id='JXS11'></ul>

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

      1. <legend id='JXS11'><style id='JXS11'><dir id='JXS11'><q id='JXS11'></q></dir></style></legend>

      2. <tfoot id='JXS11'></tfoot>

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

        如何收听 EditText?

        时间:2023-10-01
      3. <i id='m2Jsh'><tr id='m2Jsh'><dt id='m2Jsh'><q id='m2Jsh'><span id='m2Jsh'><b id='m2Jsh'><form id='m2Jsh'><ins id='m2Jsh'></ins><ul id='m2Jsh'></ul><sub id='m2Jsh'></sub></form><legend id='m2Jsh'></legend><bdo id='m2Jsh'><pre id='m2Jsh'><center id='m2Jsh'></center></pre></bdo></b><th id='m2Jsh'></th></span></q></dt></tr></i><div id='m2Jsh'><tfoot id='m2Jsh'></tfoot><dl id='m2Jsh'><fieldset id='m2Jsh'></fieldset></dl></div>
        • <bdo id='m2Jsh'></bdo><ul id='m2Jsh'></ul>

        • <legend id='m2Jsh'><style id='m2Jsh'><dir id='m2Jsh'><q id='m2Jsh'></q></dir></style></legend>

                  <tbody id='m2Jsh'></tbody>

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

                <tfoot id='m2Jsh'></tfoot>
                  本文介绍了如何收听 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

                • <small id='Rk050'></small><noframes id='Rk050'>

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

                      <bdo id='Rk050'></bdo><ul id='Rk050'></ul>
                    <tfoot id='Rk050'></tfoot>

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