1

I am looking to create a custom component which is a numeric keypad with dynamic increment up and down buttons like this: enter image description here

This keypad needs to also work in views with multiple EditText controls and somehow get the EditText that has Focus. Each EditText might also require different increment values (i.e. +1,000, +10, +0.002, etc.) which is why the increment buttons need to be dynamic.

I found a good example here which helps me to a certain point but this keypad is intended for one EditText field which is part of the control. My custom component needs to be re-usable in many different layouts and it also needs to receive the EditText with current focus in order to adjust the increment values.

Android custom numeric keyboard

I would prefer to use the keypad as an in various layouts so it would be visible all the time while the android keyboard is suppressed but I'm open to the idea of making this a custom keyboard that would just replace the default keyboard when the EditText is selected.

Community
  • 1
  • 1
JoeDaddy7105
  • 31
  • 1
  • 6

1 Answers1

0

getWindow().getCurrentFocus() returns the control in focus, which should be an instanceof EditText... while when intending to create a re-usable component, the EditText might require the TextView.OnEditorActionListener added, in order to display the custom component instead of the default one. it even might make sense, to create a custom version of EditText and using that instead (instead of adding an observer to several individual fields).

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • 1
    Thanks for the quick response! So if I make a custom EditText say called NumberEditText then I can constrain it to numeric input only but how would I direct it to use my custom Keypad instead of the default keyboard when it receives focus? – JoeDaddy7105 Aug 15 '16 at 19:41