久久久久久久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問題)
主站蜘蛛池模板: 日日摸夜夜添夜夜添特色大片 | 亚洲网站在线播放 | 精品久久久久久久久久久院品网 | 蜜臀av日日欢夜夜爽一区 | 天天曰天天曰 | 亚洲久久久 | 一二区成人影院电影网 | 久久精品 | 国产在线一区观看 | 精品成人免费视频 | 91精品国产91久久久久久丝袜 | 国产视频在线观看一区二区三区 | 日韩中文在线视频 | 国产不卡在线 | 亚洲视频中文字幕 | 97操操 | 久久久噜噜噜久久中文字幕色伊伊 | 美女久久视频 | 日本一区二区不卡 | 国产成人一区二区 | 亚洲一区二区综合 | 国产丝袜一区二区三区免费视频 | 中文字幕一区二区三区乱码图片 | 人妖一区 | 久久99精品久久久久久秒播九色 | 色婷婷av一区二区三区软件 | 99精品国自产在线观看 | 欧美福利视频 | 日韩高清三区 | 国产精品久久久久久久久久 | 日韩资源| 亚洲成人毛片 | 亚洲高清久久 | 欧美成人在线网站 | 亚洲精品一区在线观看 | 干干干日日日 | 久久69精品久久久久久久电影好 | 国产在线中文字幕 | 老牛嫩草一区二区三区av | 精品网站999www | 欧日韩在线观看 |