當前位置:首頁 » 安卓系統 » android只能輸入數字

android只能輸入數字

發布時間: 2024-03-17 15:44:58

『壹』 android 如何用代碼實現EditText控制項中只能輸入數字

數字<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
帶小數的數字 <EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
電話號碼的 <EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone" />

『貳』 Android EditeText 只能輸入數字與字母的組合 應該怎麼寫(詳細點的)

可以在EditText中設置屬性。

android:numeric="integer"即只能輸入整數,如<EditText

android:id="@+id/home_et_validate"

style="@style/order_vcode_input"

android:hint="請輸入訂單驗證碼"

android:inputType="number"

android:digits="@string/filter_vcode"/>

<string name="filter_vcode"></string>

這樣就可以了。

『叄』 android 中怎麼控制EditText只能輸入數字和字母,不能有漢字,字元

例子如下:
strings.xml文件:
<string name="rule_password">`¬!"£$%^*()~=#{}[];':,./?/*-_+<>@&</string>
EditText的布局文件:

<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="@string/rule_password"/>
註:在strings.xml中不能直接寫特殊符號,如@&等特殊符號,可使用ASCII碼表示。
<的ASCII碼為 <
>的ASCII碼為 >

@的ASCII碼為 @
&的ASCII碼為 &

『肆』 Android EditText只能輸入兩位小數,如:金額,錢等

1、設置輸入類型

2、添加addTextChangedListener

3、EditTextUtil

熱點內容
apmserv資料庫 發布:2025-10-17 13:26:09 瀏覽:474
dota2機器人腳本哪個適合新手 發布:2025-10-17 13:25:57 瀏覽:178
linux重命名文件的命令 發布:2025-10-17 13:00:40 瀏覽:460
python飛機 發布:2025-10-17 13:00:38 瀏覽:715
普通電腦支持伺服器硬碟 發布:2025-10-17 12:52:54 瀏覽:499
hdpiandroid 發布:2025-10-17 12:51:23 瀏覽:278
配置高的東西有哪些 發布:2025-10-17 12:48:57 瀏覽:355
老安卓手機用什麼版本微信 發布:2025-10-17 12:39:45 瀏覽:393
四軸A軸編程 發布:2025-10-17 12:39:04 瀏覽:603
java關閉的連接 發布:2025-10-17 12:34:53 瀏覽:309