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

Android:在 Number/Phone 上設置 inputType 時檢查 EditTe

Android: Check if EditText is Empty when inputType is set on Number/Phone(Android:在 Number/Phone 上設置 inputType 時檢查 EditText 是否為空)
本文介紹了Android:在 Number/Phone 上設置 inputType 時檢查 EditText 是否為空的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我在 android 中有一個 EditText 供用戶輸入他們的年齡.它設置了一個 inputType=phone.我想知道是否有辦法檢查此 EditText 是否為空.

I have an EditText in android for users to input their AGE. It is set an inputType=phone. I would like to know if there is a way to check if this EditText is null.

我已經看過這個問題:檢查EditText是否為空.但它沒有解決 inputType=phone 的情況.

I've already looked at this question: Check if EditText is empty. but it does not address the case where inputType=phone.

這些,我已經檢查過了,但不起作用:

These, I've checked already and do not work:

(EditText) findViewByID(R.id.age)).getText().toString() == null
(EditText) findViewByID(R.id.age)).getText().toString() == ""
(EditText) findViewByID(R.id.age)).getText().toString().matches("")
(EditText) findViewByID(R.id.age)).getText().toString().equals("")
(EditText) findViewByID(R.id.age)).getText().toString().equals(null)
(EditText) findViewByID(R.id.age)).getText().toString().trim().length() == 0
(EditText) findViewByID(R.id.age)).getText().toString().trim().equals("")
and isEmpty do not check for blank space.

感謝您的幫助.

推薦答案

可以使用 TextUtils 類進行檢查

You can check using the TextUtils class like

TextUtils.isEmpty(ed_text);

或者你可以這樣檢查:

EditText ed = (EditText) findViewById(R.id.age);

String ed_text = ed.getText().toString().trim();

if(ed_text.isEmpty() || ed_text.length() == 0 || ed_text.equals("") || ed_text == null)
{
    //EditText is empty
}
else
{
    //EditText is not empty
}

這篇關于Android:在 Number/Phone 上設置 inputType 時檢查 EditText 是否為空的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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問題)
主站蜘蛛池模板: 久草.com | 成人在线视频观看 | 成人在线精品视频 | 久久亚洲一区二区三区四区 | 国产亚洲一区二区三区在线观看 | 91中文字幕在线 | 欧美二区在线 | 日韩精品免费视频 | 一区二区av | 日韩视频―中文字幕 | 日韩成人高清 | 亚洲精品国产电影 | 日日噜噜噜夜夜爽爽狠狠视频, | 国产精品中文字幕在线 | 亚洲一区二区精品视频在线观看 | 狠狠色香婷婷久久亚洲精品 | 日韩视频国产 | 成人片在线看 | 国产精品日日摸夜夜添夜夜av | 天色综合网 | 午夜免费福利影院 | 一级特黄色毛片 | 欧美1区| 婷婷综合五月天 | 日韩精品久久久久 | 久久成人精品视频 | 一区二区三区国产精品 | 亚洲日本中文 | www.888www看片 | 精品国产乱码久久久久久果冻传媒 | 亚洲一区二区三区在线视频 | 国产精品免费一区二区 | 国产精品视频综合 | 国产乱码久久久久久 | 鸡毛片| 国产在线精品一区二区三区 | 亚洲一二三区在线观看 | 亚洲人精品| 狠狠爱免费视频 | 一区二区三区影院 | 日韩精品一区二区三区在线观看 |