本文介紹了如何設(shè)置 Edittext 視圖只允許兩個數(shù)值和兩個十進(jìn)制值,如 ##.##的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時送ChatGPT賬號..
我需要為 edittext 視圖設(shè)置驗(yàn)證應(yīng)該允許兩個數(shù)值和兩個十進(jìn)制值.示例:22.32
I need to set validation for a edittext view should allow two numeric values and two decimal values. example: 22.32
請告訴我如何進(jìn)行此驗(yàn)證
Please let me know how to do this validation
提前致謝
推薦答案
boolean isValid=<EditText Variable>.getText().toString().matches("\d{2}\.\d{2}");
將此方法放在 onClickListener 中,我想你會很高興的.
Put this method in a onClickListener and I guess you will be good to go.
這篇關(guān)于如何設(shè)置 Edittext 視圖只允許兩個數(shù)值和兩個十進(jìn)制值,如 ##.##的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!