2014-04-19 21 views
0

我想顯示數字鍵盤edittext時的重點。 我試圖顯示數字keyboard_android

myEditText.setInputType(InputType.TYPE_CLASS_NUMBER) 

,但隨後只接受數字作爲輸入,並忽略退格等

我只是希望那個數字鍵盤顯示,而不是字母

+0

你試過TYPE_CLASS_PHONE?它添加了一些符號(#+),空格和退格符。 – tcollart

+0

我得到了我需要的東西,謝謝!張貼它作爲一個問題,所以我可以接受它 – sparrkli

+0

完成:)祝你好運與你的應用程序! – tcollart

回答

1

做在你的XML佈局

<EditText 
android:id="@+id/myEditText" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:inputType="number" /> 
1

你有兩種方法。

做在你的佈局

<EditText 
     android:id="@+id/edittex" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="numberDecimal"/> 

或者在你的代碼。

EditText e = (EditText) findViewById(R.id.edittex); 
e.setInputType(InputType.TYPE_CLASS_NUMBER); 

,或者如果你想要一個像撥號鍵盤輸入任何東西,這將只顯示你數的d將我能夠把int值的輸入。 嘗試在代碼

e.setInputType(InputType.TYPE_CLASS_PHONE); 

或佈局

android:inputType="phone" 
+0

謝謝,這也是一個答案 – sparrkli