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

如何將我的 EditText 輸入限制為數(shù)字(可能是十進(jìn)制

How do I restrict my EditText input to numerical (possibly decimal and signed) input?(如何將我的 EditText 輸入限制為數(shù)字(可能是十進(jìn)制和有符號(hào))輸入?)
本文介紹了如何將我的 EditText 輸入限制為數(shù)字(可能是十進(jìn)制和有符號(hào))輸入?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我已閱讀 Android:將 EditText 限制為數(shù)字 和 如何在 android 的 EditText 上顯示數(shù)字鍵盤(pán)?.不幸的是,它們似乎都不符合我的需求.

I have read Android: Limiting EditText to numbers and How do I show the number keyboard on an EditText in android?. Unfortunately, none of them seems to fit my needs.

我想將我的 EditText 輸入限制為僅限數(shù)字.但是,我也希望允許有符號(hào)和/或十進(jìn)制輸入.

I want to restrict my EditText input to only numbers. However, I also want to allow signed and/or decimal input.

這是我當(dāng)前的代碼(我需要以編程方式執(zhí)行此操作):

Here is my current code (I need to do this programmatically):

EditText edit = new EditText(this);

edit.setHorizontallyScrolling(true);
edit.setInputType(InputType.TYPE_CLASS_NUMBER);

有了這個(gè),我的 EditText 愉快地將所有輸入限制為數(shù)字.不幸的是,它不允許任何其他內(nèi)容,例如小數(shù)點(diǎn).

With this, my EditText merrily restricts all input to numerical digits. Unfortunately, it doesn't allow anything else, like the decimal point.

如果我將該行更改為 edit.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL),EditText 將接受所有輸入(這不是我想要的......).

If I change that line to edit.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL), the EditText accepts all input (which isn't what I want...).

我嘗試過(guò)組合標(biāo)志(絕望地想看看它是否可行):

I've tried combining flags (in desperation to see if it would work):

edit.setInputType(InputType.TYPE_CLASS_NUMBER);
edit.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL)
edit.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED)

這也不起作用(EditText 像往常一樣接受所有輸入).

That didn't work either (the EditText accepted all input as usual).

那么,我該怎么做呢?

推薦答案

嘗試使用 TextView.setRawInputType()對(duì)應(yīng)android:inputType屬性.

這篇關(guān)于如何將我的 EditText 輸入限制為數(shù)字(可能是十進(jìn)制和有符號(hào))輸入?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測(cè)向左或向右滑動(dòng)?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉(zhuǎn)對(duì)話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點(diǎn)擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設(shè)置為僅接受 Android 中的數(shù)值?)
主站蜘蛛池模板: 亚洲视频在线一区 | 一区二区三区四区电影 | 免费黄色录像视频 | 久夜精品 | 一级做a爰片久久毛片免费看 | 成人在线视频看看 | 久久大香 | 午夜精品一区二区三区在线视频 | 国产1区2区3区 | 成人免费一区二区三区视频网站 | 91精品国产91久久久 | 国产日韩一区二区三免费高清 | 日韩成人精品一区二区三区 | 国产精品国产三级国产aⅴ中文 | 亚洲成人一二区 | 另类在线 | 懂色av蜜桃av | 欧洲一区二区三区 | 亚洲网址在线观看 | 免费精品视频在线观看 | 久久一区二区三区四区 | 国产第1页 | 亚洲 欧美 精品 | 午夜国产在线 | 美国黄色毛片 | 午夜精品一区二区三区在线观看 | 日本综合在线观看 | 欧美精品一区二区三区四区 | 中文字幕欧美在线观看 | a中文在线视频 | 欧美成人一区二区三区 | 成人午夜免费福利视频 | 国产高清一区二区三区 | 综合第一页 | 久久亚洲天堂 | 毛片a级| 亚洲成人高清 | 国产视频线观看永久免费 | 国产亚洲精品精品国产亚洲综合 | 狠狠干天天干 | 玖玖国产精品视频 |