B4A Library [Lib] Masked EditText

This EditText fixes a few issues with the standard EditText and adds new features:
- Filter: you can transform any input before the text is changed;
- Mask: you can define an input mask;
- Read-only: you can protect your EditText against changes;
- Floating hint: the hint moves above the EditText when the user starts typing;
- Error popup: you can display a message in a popup to warn the user:

met.png


v1.1:
- It is now a custom view supported by the designer
- I fixed a bug when Format was set after WithSuggestions

v1.2:
- I moved the CompactText function from the example to the library;
- I fixed a bug with SelectionStart;
- I fixed a bug when InputType is set to NONE.

v1.3:
- WithSuggestions works now as expected on Samsung devices.
- Suggestions are automatically disabled in password mode.

v1.4:
- I added the EnableFloatingHint function;
- I added the custom view properties for the designer.

v1.41:
- I improved the animation of the floating hint;
- I fixed an issue with the hint color.

v1.42:
- I fixed a bug with the floating hint when the EditText is moved.

v1.5:
- I rewrote the code of floating hints to make it more robust and fix a few issues;
- I added the SetFromHTML function.

v1.51:
- A few properties set in the designer were not taken into account.

v1.52:
- There was an issue with the background drawable as it was set by default by the designer to a white colored drawable. The support of this property in the designer was removed to keep the original default background.

This library does not work with Android versions < 2.
 

Attachments

  • MaskedEditText v1.52.zip
    24.9 KB · Views: 2,741
  • Java source - MaskedEditText.zip
    9.2 KB · Views: 1,108
  • MaskedEditText v1.53.zip
    25.2 KB · Views: 1,720
Last edited:

Roberto Cardenas

Member
Licensed User
Longtime User
I don't know what is sf.Pad. It seems the problem comes from this function.
Hello,thanks for your quick response.
Sf.pad is a string function to put fill with "0" the string. But neither work if I assign it the value as is txtamount.Text = 220.50

Thanks.
Robert
 

Informatix

Expert
Licensed User
Longtime User
Hello,thanks for your quick response.
Sf.pad is a string function to put fill with "0" the string. But neither work if I assign it the value as is txtamount.Text = 220.50

Thanks.
Robert
Yes, it's normal. You have to use the NumberFormat function to convert your number into a string. In your case, you have to do:
txtamount.PlaceHolder = "0"
txtamount.Text = NumberFormat(your number, 6, 2)

PS: avoid using "," if your application is international because it's extremely confusing for european people which use "," as a decimal mark. Space is now the international character used to group digits by three.
 

Roberto Cardenas

Member
Licensed User
Longtime User
Yes, it's normal. You have to use the NumberFormat function to convert your number into a string. In your case, you have to do:
txtamount.PlaceHolder = "0"
txtamount.Text = NumberFormat(your number, 6, 2)

PS: avoid using "," if your application is international because it's extremely confusing for european people which use "," as a decimal mark. Space is now the international character used to group digits by three.

Thanks a lot, that make it work :)

Also thanks for the tip about the internationalization, I'll use the space instead the ",".

Best Regards,
Robert
 

GaNdAlF89

Active Member
Licensed User
Longtime User
B4X:
src\flm\b4a\metdemo\main.java:213: error: cannot access DesignerCustomView
mostCurrent._v5.Initialize(mostCurrent.activityBA,"ET1");
               ^
  class file for anywheresoftware.b4a.keywords.Common$DesignerCustomView not found
1 error
I get this error during compiling your example. What is the problem?
 

ArminKH

Well-Known Member
thank u this great lib
but i there any way to change the background color of error popup?
because when my theme(on manifest) is Holo.Light then error popup 's background color is black and thats not seem good
i use your lib on custom dialog
please see attached screenshot
thanks again
 

Attachments

  • Screenshot_2015-04-04-02-48-08.png
    Screenshot_2015-04-04-02-48-08.png
    9.2 KB · Views: 374

ArminKH

Well-Known Member
@Informatix
Thats not possible by using nine patch?
Ok i dont know, thats just a suggestion :)
Before i think the error popup is custom view or a panel
Thank u
 

Geritt Schlag

Member
Licensed User
Longtime User
Thanks for the good library!

I have a problem with IPs.
Formatstring "###.###.###.###" allowed no input as "162.198.1.100".
And "162.198.001.100" is not correct in the network.

Who can help?
 

Arf

Well-Known Member
Licensed User
Longtime User
Hi, using this library fixed my 'no suggestions' problem on the Galaxy phone, thanks.

One question - is there any way I can get the text to justify to the middle of the box rather than the left?
Here is what I have at the moment:

B4X:
NameEntry.InputType = NameEntry.INPUT_TYPE_TEXT
NameEntry.SingleLine = True
NameEntry.WithSuggestions = False
 

Informatix

Expert
Licensed User
Longtime User
Hi, using this library fixed my 'no suggestions' problem on the Galaxy phone, thanks.

One question - is there any way I can get the text to justify to the middle of the box rather than the left?
Here is what I have at the moment:

B4X:
NameEntry.InputType = NameEntry.INPUT_TYPE_TEXT
NameEntry.SingleLine = True
NameEntry.WithSuggestions = False
Use Gravity.
 
Top