开发者

touchscreen keypad

I am developing an application for Android.开发者_Go百科

I need to display a numeric keypad on the screen.

How can this be achieved?


I've been struggling with this myself. I've not been able to present and entirely numeric only keypad, but you get closest with this combination:

<EditText
  android:id="@+id/someid"
  android:inputType="phone"
  android:numeric="integer"
</EditText>

The inputType="phone" changes the keypad from the normal keypad to one with fewer, bigger buttons (whereas inputType="numberDecimal" uses the normal keypad, but starting on the number keyset) and the numeric="integer" means anything except numbers are ignored (i.e. they don't even appear in the EditText). There's also a numeric="decimal" if that's what you're after.


What needs the numeric input? If it's an EditText, main.xml should have an entry like

<EditText
        android:id="@+id/someid"
        android:inputType="numberDecimal">
</EditText>

This would show the number pad when the user taps the input field.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜