久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='RoiWu'></tfoot>
    <i id='RoiWu'><tr id='RoiWu'><dt id='RoiWu'><q id='RoiWu'><span id='RoiWu'><b id='RoiWu'><form id='RoiWu'><ins id='RoiWu'></ins><ul id='RoiWu'></ul><sub id='RoiWu'></sub></form><legend id='RoiWu'></legend><bdo id='RoiWu'><pre id='RoiWu'><center id='RoiWu'></center></pre></bdo></b><th id='RoiWu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RoiWu'><tfoot id='RoiWu'></tfoot><dl id='RoiWu'><fieldset id='RoiWu'></fieldset></dl></div>
    • <bdo id='RoiWu'></bdo><ul id='RoiWu'></ul>
    1. <small id='RoiWu'></small><noframes id='RoiWu'>

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

      1. 如何使用 TextWatcher 更新相同的 EditText?

        How to update the same EditText using TextWatcher?(如何使用 TextWatcher 更新相同的 EditText?)
        <tfoot id='VAXFu'></tfoot>
            <bdo id='VAXFu'></bdo><ul id='VAXFu'></ul>

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

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

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

                • 本文介紹了如何使用 TextWatcher 更新相同的 EditText?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  在我的 Android 應(yīng)用程序中,我需要實(shí)現(xiàn)一個(gè) TextWatcher 接口來(lái)實(shí)現(xiàn) onTextChanged.我遇到的問(wèn)題是,我想用一些額外的字符串更新相同的 EditText.當(dāng)我嘗試這樣做時(shí),程序會(huì)終止.

                  In my Android application I need to implement a TextWatcher interface to implement onTextChanged. The problem I have is, I want to update the same EditText With some extra string. When I try to do this the program terminates.

                   final EditText ET = (EditText) findViewById(R.id.editText1);
                   ET.addTextChangedListener(new TextWatcher() {
                  
                          @Override
                          public void onTextChanged(CharSequence s, int start, int before, int count)
                          {
                              try
                              {
                                   ET.setText("***"+ s.toString());
                                   ET.setSelection(s.length());
                              }
                              catch(Exception e)
                              {
                                  Log.v("State", e.getMessage());
                              }
                          }
                  
                          @Override
                          public void beforeTextChanged(CharSequence s, int start, int count, int after)
                          {
                  
                          }
                  
                          @Override
                          public void afterTextChanged(Editable s)
                          {               
                          }
                      });
                  

                  我的程序終止了,即使我嘗試在我的代碼中捕獲異常,它仍然終止.有誰(shuí)知道為什么會(huì)發(fā)生這種情況以及我如何做到這一點(diǎn)?謝謝.

                  My program terminates and even I try to catch the exception like in my code still it terminates. Does anyone have any idea why this happens and how I can achieve this? Thanks.

                  推薦答案

                  TextView 的內(nèi)容在 onTextChanged 事件上不可編輯.

                  The content of the TextView is uneditable on the onTextChanged event.

                  相反,您需要處理 afterTextChanged 事件才能對(duì)文本進(jìn)行更改.

                  Instead, you need to handle the afterTextChanged event to be able to make changes to the text.

                  更詳盡的解釋參見(jiàn):Android TextWatcher.afterTextChanged vs TextWatcher.onTextChanged

                  注意:錯(cuò)誤onTextChanged

                  顯然,您正在通過(guò)不斷更改 afterTextChanged 事件上的 text 導(dǎo)致無(wú)限循環(huán).

                  Obvioulsy, you are causing an endless loop by continuously changing the text on afterTextChanged event.

                  來(lái)自 參考:

                  public abstract void afterTextChanged (Editable s)
                  調(diào)用此方法是為了通知您,在 s 中的某處,文本已被改變了.從此對(duì) s 進(jìn)行進(jìn)一步更改是合法的回調(diào),但注意不要讓自己陷入無(wú)限循環(huán),因?yàn)槟龅娜魏胃亩紩?huì)導(dǎo)致再次調(diào)用此方法遞歸地....

                  • 建議1:如果可以的話,檢查s是否已經(jīng)在事件觸發(fā)時(shí)是你想要的.

                    • Suggestion 1: if you can, check if the s is already what you want when the event is triggered.

                      @Override
                      public void afterTextChanged(Editable s)
                      {    
                          if( !s.equalsIngoreCase("smth defined previously"))
                               s = "smth defined previously";              
                      }
                      

                    • 建議 2:如果您需要做更復(fù)雜的事情(格式化、驗(yàn)證)您可以使用 synchronized 方法-textwatcher">這個(gè)發(fā)帖.
                    • Suggestion 2: if you need to do more complex stuff (formatting, validation) you can maybe use a synchronized method like in this post.
                    • 注意 2:將輸入格式化為部分隱藏,并用 n 個(gè)星號(hào)直到最后一個(gè) 4 個(gè)字符(****四個(gè))

                      Note 2 : Formatting the input as partially hidden with n stars till the last 4 chars ( ****four)

                      您可以在建議 1 中使用類似的內(nèi)容:

                      You can use something like this in suggestion 1:

                          @Override
                          public void afterTextChanged(Editable s)
                          {    
                             String sText = ET.getText().toString()
                      
                              if( !isFormatted(sText))
                                   s = format(sText);              
                          }
                          bool isFormatted(String s)
                          {
                           //check if s is already formatted
                          }
                      
                          string format(String s)
                          {
                            //format s & return
                          }
                      

                      這篇關(guān)于如何使用 TextWatcher 更新相同的 EditText?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                      【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語(yǔ)句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)

                  <small id='521e2'></small><noframes id='521e2'>

                  <tfoot id='521e2'></tfoot>

                    • <bdo id='521e2'></bdo><ul id='521e2'></ul>

                          <tbody id='521e2'></tbody>
                        <i id='521e2'><tr id='521e2'><dt id='521e2'><q id='521e2'><span id='521e2'><b id='521e2'><form id='521e2'><ins id='521e2'></ins><ul id='521e2'></ul><sub id='521e2'></sub></form><legend id='521e2'></legend><bdo id='521e2'><pre id='521e2'><center id='521e2'></center></pre></bdo></b><th id='521e2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='521e2'><tfoot id='521e2'></tfoot><dl id='521e2'><fieldset id='521e2'></fieldset></dl></div>
                        <legend id='521e2'><style id='521e2'><dir id='521e2'><q id='521e2'></q></dir></style></legend>

                            主站蜘蛛池模板: 欧美一区二区三 | 日韩精品 电影一区 亚洲 | 欧美福利| 免费色网址 | 男女视频在线免费观看 | 在线视频亚洲 | 日韩一区欧美一区 | 久草免费视 | 国产精彩视频 | 久久午夜电影 | 九九综合 | 亚洲一区二区视频在线观看 | 求个av网址 | 一二三区av| 国产精品高清一区二区三区 | 国产一区二区免费 | 国产一区二区不卡 | 国产精品福利久久久 | 亚洲精品成人av久久 | 欧洲一区二区三区 | 久久国产精品亚洲 | 欧美一级在线 | 国产精品看片 | 日韩精品久久久久久 | 粉嫩一区二区三区国产精品 | 国产精品久久国产精品99 | 一级毛片成人免费看a | 欧美一级大片免费观看 | 日日干天天操 | 欧美日韩久 | 久久久久久看片 | 国产h视频 | 久久精品一区 | 久久激情视频 | 亚洲国产精品一区二区第一页 | 北条麻妃av一区二区三区 | 亚洲精品一区二区在线观看 | av在线免费看网址 | 久久久久久免费精品一区二区三区 | 精精国产xxxx视频在线播放 | 国产伦精品一区二区三区精品视频 |