2

I'm working on a checkbook app, and I'd like to use a small widget like a TimePickerDialog or DatePickerDialog but one that acts like a keypad so the user can enter an account or transaction balance. I know I can use an EditText but I would like to be able to implement a keypad.

Does Android have any predefined UI elements to support this? I have tried to find some, but without luck. I did find an interesting article to implement my own using a GridLayout, but wondered if someone was aware of any Android classes that could already do this.

The GridLayout method: http://code.tutsplus.com/tutorials/android-user-interface-design-creating-a-numeric-keypad-with-gridlayout--mobile-8677

AdamMc331
  • 15,982
  • 9
  • 67
  • 128

2 Answers2

2

If you specify android:inputType="numberDecimal" in the XML for your EditText, you'll get a keypad. If you decide that you need a more specialized keyboard, there's a very good tutorial here.

scottt
  • 8,141
  • 1
  • 30
  • 39
  • Thanks! I had tried to come up with something more unique, almost like it's own activity but an edit text will do just fine. I'm going to bookmark that tutorial though incase I use it in the future. I found this other question (for anyone who reads this and might want to use a keypad) that explains how to use a filter for EditTexts. They're especially useful for a checkbook app, because all dollar amounts will be limited to two decimal places: http://stackoverflow.com/questions/5357455/limit-decimal-places-in-android-edittext – AdamMc331 Jun 15 '14 at 23:43
1

Some tips:

  1. Read this tutorial: Creating an Input Method
  2. Clone this repo: LatinIME
Snehal Masne
  • 3,225
  • 3
  • 29
  • 49
  • Thanks for the tutorial. That actually was what I was looking for, but I decided for this project an EditText was the simplest way to accomplish what I wanted to do. I'm definitely going to hold on to this for later. – AdamMc331 Jun 15 '14 at 23:44