Android Question Flawless Control of Decimal Numbers

David S

Member
Licensed User
Longtime User
I've been trying to control the way decimal numbers are input and displayed with the EditText control (input type decimal), but I am pretty unhappy with the result.

It's difficult to get the keyboard to pre-open. Selecting all the text does not help. Setting the cursor at the end of the text works only once when focus is changed or text is changed. If you tap anywhere on the number more than once that is where the cursor ends up. Oh, and even though I have the FORCE DONE parameter set to FALSE, the keyboard still displays DONE instead of NEXT.

I do know of a simple program with flawless control of decimal numbers. Its called TipMe and he/she/they did a great job on this well done Tip program. I love the way the amounts are input.

Here is a MP4 video of it: https://www.dropbox.com/s/y83ejonjgcmokxq/MotoX_Capture TipMe.mp4?dl=0

The only way I can figure out to do the same in B4A is to have a label next to a very narrow edittext view with a width of 1 or 2. As the user inputs a character you update the preceding label's text from right to left.

Does anyone else know how to emulate the way the TipMe programs handles amounts?

Thanks!,
David
 
Last edited:

David S

Member
Licensed User
Longtime User
You can use CallSubDelayed to move the cursor to the end of the string.

Thanks Erel for the reply. I had put this down for a while and I am just getting back to it.

So you mean I should create a sub where I set the cursor to the last position?

CallSubDelayed(inputAmtEditText, PositionCursorToEndOfField)​

I am trying to understand when I should use the CallSubdelayed. Is there a rule of thumb? Maybe the rule is never use CallSub when a control... opps.... I mean "view" .... is involved?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached you find a small project showing a solution.
It uses Labels to show the data instead of EditText views and a custom keyboard instead of the internal keyboard.
Feel free to adapt it to your requirements.
 

Attachments

  • DecimalInput.zip
    13.4 KB · Views: 140
Upvote 0

David S

Member
Licensed User
Longtime User
Attached you find a small project showing a solution.
It uses Labels to show the data instead of EditText views and a custom keyboard instead of the internal keyboard.
Feel free to adapt it to your requirements.


Thanks ! i'll look it over... I did use labels to, but wasn't using a custom keyboard.
 
Upvote 0
Top