BlacKCaT27 / CurrencyEditText

A module designed to encapsulate the use of an Android EditText field for gathering currency information from a user. Supports all ISO-3166 compliant locales/currencies.
Apache License 2.0
339 stars 79 forks source link

Inability to set edittext to allow negative values #39

Open amcknight00 opened 7 years ago

amcknight00 commented 7 years ago

I have set the hint to an empty string but it still shows up with the pound sign as that is the region I am in. I have used this code: editAmountexpense.setHint(""); Where editAmountExpense is the CurrencyEditText, and I still get the currency sign. I am doing this because I want to turn the raw entered value to a float with 2 decimal places but without the hint in front.

BlacKCaT27 commented 6 years ago

Sorry for the delayed response.

Hm. Setting the hint to an empty string should remove the symbol. If not, that's a bug. I'll have to verify later. You can set it to a single space character to for sure hide it.

Having said that, successfully hiding the hint isn't going to solve your actual problem. The hint doesn't feed into the string that is displayed; they're separate strings. Calling getText() will get you the value shown to the user with the symbol even if the hint is disabled.

What you want to do is call getRawValue(). This returns the value input by the user as an integer (e.g. 1000 for "$10.00".) You can then manipulate the integer to get whatever value you want (divide by 100 for 2 decimal places, etc).

amcknight00 commented 6 years ago

Sorry for the late reply, Thanks for our response. I ended up changing Locale to change the hint. Even though this works I am having trouble setting the edittext to allow negative input. I have tried adding the "app:allow_negative_values="true"" and adding it through JAVA aswell but I have had no luck. Do you have any suggestions?