當前位置:首頁 » 安卓系統 » 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

熱點內容
java小數正則表達式 發布:2025-05-20 11:30:58 瀏覽:136
文件夾加密win7 發布:2025-05-20 11:27:46 瀏覽:837
壓縮文件設置密碼有什麼意思 發布:2025-05-20 11:26:37 瀏覽:551
造夢西遊qq登錄如何修改密碼 發布:2025-05-20 11:18:36 瀏覽:382
淘寶緩存清理後還是大 發布:2025-05-20 11:15:39 瀏覽:149
ios雲存儲自動訂購 發布:2025-05-20 11:06:22 瀏覽:110
編程與數學 發布:2025-05-20 11:01:23 瀏覽:444
asp連接遠程資料庫 發布:2025-05-20 10:50:20 瀏覽:390
一般電腦配置哪個好 發布:2025-05-20 10:40:58 瀏覽:604
我的世界擼樹伺服器 發布:2025-05-20 10:33:37 瀏覽:742