久久久久久久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的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我有一些代碼,如果 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 語句,如果 editText 字段中的字符少于 3 個(gè),則禁用按鈕,但是在輸入時(shí),當(dāng)用戶插入 3 個(gè)字符時(shí),它不會(huì)重新評估該語句是否為真所以按鈕當(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 然后覆蓋其方法,并從下面的鏈接示例中檢查長度

                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.

                重寫

                上面可以清理為

                @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)令人困惑.您說輸入三(3)",這聽起來正好是 3,但您的代碼看起來不同.無論如何,這對你來說很容易改變.

                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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(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>
                        • 主站蜘蛛池模板: 欧美日韩在线一区二区 | 特黄特黄a级毛片免费专区 av网站免费在线观看 | 欧美a级成人淫片免费看 | 亚洲视频 欧美视频 | 亚洲精品白浆高清久久久久久 | 天天插天天搞 | 欧美一区二区黄 | 国产传媒 | 色免费看 | 亚洲欧美精| 我想看国产一级毛片 | 视频在线亚洲 | 日韩欧美一区二区三区免费观看 | 日本成人片在线观看 | 中文字幕在线看第二 | 懂色中文一区二区三区在线视频 | 亚洲免费在线视频 | 日韩网站在线 | 日日日日日日bbbbb视频 | 日韩精品成人在线 | 爱高潮www亚洲精品 中文字幕免费视频 | 国产精品亚洲一区 | 一区二区国产精品 | 欧美一区二 | 亚洲综合免费 | 久久影音先锋 | 午夜在线观看免费 | 色欧美片视频在线观看 | 国产欧美一区二区三区久久人妖 | 国产成人精品999在线观看 | www312aⅴ欧美在线看 | 中文字幕高清 | 成人免费视频观看视频 | 欧美日本韩国一区二区 | 91av在线影院| www久久国产| 九一国产精品 | 中文字幕韩在线第一页 | 国产91在线 | 亚洲 | 久久国产视频网站 | 国产欧美日韩一区 |