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

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

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

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

      Android - 在用戶輸入之前和之后檢查editText是否&

      Android - Checking if editText is gt;3 before and after user input(Android - 在用戶輸入之前和之后檢查editText是否 3)
        <legend id='F8HGI'><style id='F8HGI'><dir id='F8HGI'><q id='F8HGI'></q></dir></style></legend><tfoot id='F8HGI'></tfoot>

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

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

                <tbody id='F8HGI'></tbody>
                <bdo id='F8HGI'></bdo><ul id='F8HGI'></ul>

              • 本文介紹了Android - 在用戶輸入之前和之后檢查editText是否> 3的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                我有一些代碼,如果 editText 字段中的字符少于 3 個(gè),我需要禁用創(chuàng)建帳戶"按鈕.如果用戶輸入 3 個(gè)字符,則該按鈕應(yīng)啟用自身以便可以使用.

                I have some code where I need a "Create Account" button to be disabled if an editText field has less than 3 char in it. If the User enters 3 chars, then the button should enable itself so that it can be used.

                我已經(jīng)構(gòu)建了 if else 語(yǔ)句,如果 editText 字段中的字符少于 3 個(gè),則禁用按鈕,但是在輸入時(shí),當(dāng)用戶插入 3 個(gè)字符時(shí),它不會(huì)重新評(píng)估該語(yǔ)句是否為真所以按鈕當(dāng)然會(huì)保持禁用狀態(tài).

                I have constructed the if else statement that disables the button if there are less than 3 char in the editText field, BUT on input, when the user inserts 3 char, it does not re-evaluate to see if the statement is true so the button of course stays disabled.

                一旦用戶在編輯文本字段中輸入 3 個(gè)字符,按鈕應(yīng)該會(huì)自行啟用.

                Once the user enters 3 char into the edit text field, the button should enable itself.

                    Button buttonGenerate = (Button) findViewById(R.id.btnOpenAccountCreate);
                    userInitials = (EditText) findViewById(R.id.etUserChar);
                    if (userInitials.getText().toString().length() > 3) {
                                // Account Generator Button
                                            buttonGenerate.setEnabled(true); // enable button;
                                            buttonGenerate.setOnClickListener(new OnClickListener() { 
                //Do cool stuff here
                                                @Override
                                                public void onClick(View v) {
                
                                                }
                                            });// END BUTTON
                            } else {
                
                                // If UserInitials is empty, disable button
                                            Toast.makeText(this, "Please enter three(3) characters in the Initials Field ", Toast.LENGTH_LONG)
                                                    .show();
                                            buttonGenerate.setEnabled(false); // disable button;
                            }// END IF ELSE
                

                推薦答案

                你想使用一個(gè) TextWatcher

                每當(dāng)您的 EditText 中具有此 listener 的文本發(fā)生更改時(shí),都會(huì)觸發(fā)此事件.您只需像其他任何 listener 一樣將 listener 附加到您的 EditText 然后覆蓋其方法,并從下面的鏈接示例中檢查長(zhǎng)度

                This will be triggered each time the text in your EditText which has this listener on it has changed. You just attach the listener to your EditText like you would any other listener then override its methods and , from the linked example below, check the length

                 @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) 
                {   
                     if (s.length() > 2) 
                     {
                         buttonGenerate.setEnabled(true);
                     }
                     else
                    {
                         buttonGenerate.setEnabled(true);
                    }
                }
                

                您不需要簽入您的 onClick() 然后,只需默認(rèn)禁用 Button 并在您的 onTextChanged() 如果滿足條件.

                You don't need to check in your onClick() then, just disable the Button by default and enable in your onTextChanged() if the condition is met.

                重寫(xiě)

                上面可以清理為

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {   
                     buttonGenerate.setEnabled((s.length() > 2));
                }
                

                我也改成了>2 因?yàn)槲艺J(rèn)為這實(shí)際上是你想要的,但你擁有它的方式有點(diǎn)令人困惑.您說(shuō)輸入三(3)",這聽(tīng)起來(lái)正好是 3,但您的代碼看起來(lái)不同.無(wú)論如何,這對(duì)你來(lái)說(shuō)很容易改變.

                I also have changed it to > 2 because I think that's actually what you want but the way you have it is a little confusing. You say "enter three(3)" which sounds like exactly 3 but your code looks different. Anyway, that's easy enough for you to change.

                查看這個(gè)答案的例子

                這篇關(guān)于Android - 在用戶輸入之前和之后檢查editText是否> 3的文章就介紹到這了,希望我們推薦的答案對(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?)
                  <bdo id='x9VY9'></bdo><ul id='x9VY9'></ul>

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

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

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

                        <tbody id='x9VY9'></tbody>
                        • 主站蜘蛛池模板: 欧美成人精品一区二区男人看 | 欧美一区二区 | 中文字幕在线精品 | 国产精品久久精品 | 国产精品亚洲综合 | 久久久国产一区二区三区 | 毛片在线免费 | 亚洲一级黄色 | 国产精品成人在线观看 | 成人h视频 | 中文字幕日韩欧美一区二区三区 | 91xh98hx 在线 国产 | 亚洲欧美中文日韩在线v日本 | 久久精品免费一区二区 | 91人人在线| 青青草一区 | a级大片免费观看 | 日韩精品在线视频 | 韩国欧洲一级毛片 | 日韩二三区 | 国产精品99久久久久久动医院 | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 欧美视频 亚洲视频 | 精品欧美一区二区三区久久久 | 亚洲免费久久久 | 亚洲一区二区三区在线视频 | 日韩精品视频一区二区三区 | 女人av| 精品视频一区二区三区在线观看 | 97色在线观看免费视频 | 成人在线免费观看 | 91精品国产91久久综合桃花 | 性色的免费视频 | 色婷婷综合久久久中字幕精品久久 | 亚洲精品在线免费播放 | 欧美一区免费 | 一区二区国产精品 | 在线国产一区二区三区 | 欧美日韩亚洲一区 | 电影午夜精品一区二区三区 | 特黄小视频 |