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

EditText 最小長度 &啟動新活動

EditText Minimum Length amp; Launch New Activity(EditText 最小長度 amp;啟動新活動)
本文介紹了EditText 最小長度 &啟動新活動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我對 Android 中的 EditText 函數有幾個疑問.

I have a couple of queries regarding the EditText function in Android.

首先,是否可以在 EditText 字段中設置最小字符數?我知道有一個

First of all, is it possible to set a minimum number of characters in the EditText field? I'm aware that there is an

android:maxLength="*"

但是由于某種原因你不能擁有

however for some reason you can't have

android:minLength="*"

另外,我想知道是否可以在按下鍵盤上的 Enter 鍵后啟動一個新活動,當我們在 EditText 字段中輸入數據時彈出我們?如果是這樣,有人可以告訴我怎么做嗎?

Also, I was wondering if it is possible to launch a new activity after pressing the enter key on the keyboard that pops us when inputing data into the EditText field? And if so, could someone show me how?

感謝您就這兩個問題提供的任何幫助:)

Thanks for any help you could offer regarding either question :)

推薦答案

響應編輯字段中的回車鍵并在用戶輸入的文本不足時通知用戶:

To respond to an enter key in your edit field and notify the user if they haven't entered enough text:

EditText myEdit = (EditText) findViewById(R.id.myedittext);
    myEdit.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                if (myEdit.getText().length() < minLength) {
                    Toast.makeText(CurrentActivity.this, "Not enough characters", Toast.LENGTH_SHORT);
                } else {
                    startActivity(new Intent(CurrentActivity.this, ActivityToLaunch.class);
                }
                return true;
            }
            return false;
        }
    });

在編輯字段時,沒有簡單的方法來強制設置最小長度.您將檢查輸入的每個字符的長度,然后在用戶嘗試刪除超過最小值時拋出擊鍵.這很混亂,這就是為什么沒有內置的方法來做到這一點.

There's no simple way to force a minimum length as the field is edited. You'd check the length on every character entered and then throw out keystrokes when the user attempt to delete past the minimum. It's pretty messy which is why there's no built-in way to do it.

這篇關于EditText 最小長度 &amp;啟動新活動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 国产中文字幕在线 | 五月综合激情婷婷 | 一级黄色片网站 | 亚洲国产一区二区三区 | 一级欧美视频 | 国内成人免费视频 | 亚洲精品一区二区在线 | 国产精品成人一区二区三区夜夜夜 | 国产成人在线视频 | 亚洲精品欧美一区二区三区 | 伊人免费在线观看高清 | 亚洲成人网在线 | 国产精品免费观看 | 亚洲成人一区二区 | 日韩精品在线视频 | 日韩有码一区 | 天天干天天草 | 日韩欧美电影在线 | 欧美日韩电影一区二区 | 天天色影视综合 | 91一区二区三区 | 久久高清国产视频 | 九色视频网站 | 天天拍天天操 | 精国产品一区二区三区四季综 | 日韩视频免费在线 | 91久久国产综合久久 | 狠狠av| 久久精品欧美一区二区三区不卡 | 羞羞视频免费观看 | 中文一区二区视频 | 91色视频在线观看 | 在线观看日韩 | 国产精品xxxx | 日韩a在线 | 日本成人免费网站 | 免费人成在线观看网站 | 91综合在线观看 | 黄色在线免费观看视频 | 日本久久久影视 | 国产精品福利视频 |