{"id":23431156,"url":"https://github.com/akamud/numericedittext-xamarin.android","last_synced_at":"2025-06-18T06:32:54.019Z","repository":{"id":1863983,"uuid":"44864640","full_name":"akamud/NumericEditText-Xamarin.Android","owner":"akamud","description":"A NumericEditText for Xamarin.Android that accepts decimal numbers that work with any culture","archived":false,"fork":false,"pushed_at":"2017-07-03T14:56:04.000Z","size":452,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-25T09:41:15.220Z","etag":null,"topics":["xamarin","xamarin-android","xamarin-components","xamarin-plugin"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akamud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-24T12:14:32.000Z","updated_at":"2023-04-26T20:17:20.000Z","dependencies_parsed_at":"2022-08-06T11:15:16.317Z","dependency_job_id":null,"html_url":"https://github.com/akamud/NumericEditText-Xamarin.Android","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/akamud/NumericEditText-Xamarin.Android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamud%2FNumericEditText-Xamarin.Android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamud%2FNumericEditText-Xamarin.Android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamud%2FNumericEditText-Xamarin.Android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamud%2FNumericEditText-Xamarin.Android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akamud","download_url":"https://codeload.github.com/akamud/NumericEditText-Xamarin.Android/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamud%2FNumericEditText-Xamarin.Android/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260506382,"owners_count":23019410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["xamarin","xamarin-android","xamarin-components","xamarin-plugin"],"created_at":"2024-12-23T09:53:40.611Z","updated_at":"2025-06-18T06:32:48.988Z","avatar_url":"https://github.com/akamud.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NumericEditText-Xamarin.Android\n![](https://raw.githubusercontent.com/akamud/NumericEditText-Xamarin.Android/master/art/Icon.png)\n\nA NumericEditText for Xamarin.Android that accepts decimal numbers that work with any culture\n\nIt will automatically get the phone's language using `CultureInfo.CurrentCulture` to figure out which characters to use as `CurrencyGroupSeparator` and `NumberDecimalSeparator` and automatically add them as you type.\n\n## Installing\n![](https://img.shields.io/nuget/v/NumericEditText-Xamarin.Android.svg?style=flat)  \n[NuGet package](https://www.nuget.org/packages/NumericEditText-Xamarin.Android/) available:\n```\nPM\u003e Install-Package NumericEditText-Xamarin.Android\n```\n\n## Using\n Add the `res-auto` namespace:\n```XML\nxmlns:num=\"http://schemas.android.comas/apk/res-auto\"\n```\nThen you can just use the component like so:\n```XML\n\u003cbr.com.akamud.NumericEditText \n\tandroid:id=\"@+id/txtNumeric\"\n\tandroid:layout_width=\"match_parent\"\n\tandroid:layout_height=\"wrap_content\"\n\tandroid:inputType=\"number|numberDecimal\" /\u003e\n```\n\nTo get the number typed without mask you can use the method `GetNumericValue()`. If the input is invalid it will return a `double.NaN`.\n\n```C#\ndouble number = txtNumeric.GetNumericValue();\n```\n\nIf you want it to return `0` when the input is invalid (like empty) you can use `GetNumericValueOrDefault()`:\n\n```C#\ndouble number = txtNumeric.GetNumericValueOrDefault();\n```\n\n### Changing precision\nBy default it uses 2 decimal digits and (virtually) infinite number digits, but you can change it to whatever you need using two attributes:  \n\nAttribute | Description | Default Value  \n:----: | :-------: | :---------:  \nmaxDigitsBeforeDecimal | Sets the maximum number of digits before the decimal point | 0 (infinite)   \nmaxDigitsAfterDecimal | Sets the maximum number of digits after the decimal point | 2\n\n```XML\n\u003cbr.com.akamud.NumericEditText \n\tandroid:id=\"@+id/txtNumeric\"\n\tandroid:layout_width=\"match_parent\"\n\tandroid:layout_height=\"wrap_content\"\n\tandroid:inputType=\"number|numberDecimal\"\n\tnum:maxDigitsBeforeDecimal=\"6\"\n\tnum:maxDigitsAfterDecimal=\"4\" /\u003e\n```\n\nYou can also change it programmatically\n```C#\ntxtNumeric.MaxDigitsBeforeDecimal = 6;\ntxtNumeric.MaxDigitsAfterDecimal = 4;\n```\n\n### Events\n`NumericEditText` fires two events:  \n`NumericValueChanged` when the value typed is changed  \n`NumericValueCleared` when the input is cleared  \nYou can use them like a regular event:\n\n```C#\ntxtNumeric.NumericValueCleared += (object sender, NumericValueClearedEventArgs e) =\u003e { \n\t// Value cleared\n};\n\ntxtNumeric.NumericValueChanged += (object sender, NumericValueChangedEventArgs e) =\u003e { \n\tdouble newValue = e.NewValue;\n\t// New value\n};\n```\n\n## Examples  \nUsing `en-US` culture:  \nInput:\n```\n100,000.00\n```\nOutput:\n```\n// double\n100000.00\n```\n\nUsing `pt-BR` culture:  \nInput:\n```\n100.000,00\n```\nOutput:\n```\n// double\n100000.00\n```\n\n## Gif examples\n### en-US culture:\n![en-US gif](https://raw.githubusercontent.com/akamud/NumericEditText-Xamarin.Android/master/enus-sample.gif)\n\n### pt-BR culture:\n![pt-BR gif](https://raw.githubusercontent.com/akamud/NumericEditText-Xamarin.Android/master/ptbr-sample.gif)\n\n## Motivation\nThe original Android EditText has [this annoying bug](https://code.google.com/p/android/issues/detail?id=2626) when used with `inputType=\"number|numberDecimal\"`, it won't work for different cultures that use different decimal separators (like pt-BR's `,` (comma)), so you can't have it accept `105,60` as a valid number.\n\nThis project is based on two other projects:  \n[Android-NumberEditText](https://github.com/hyperax/Android-NumberEditText) by [@hyperax](https://github.com/hyperax)  \n[numeric-edittext](https://github.com/hidroh/numeric-edittext) by [@hidroh](https://github.com/hidroh)\n\nThey were adapted to fit my goals, it is a bit hacky but  I think someone else might find it useful.\n\n## License\n[MIT License](https://github.com/akamud/NumericEditText-Xamarin.Android/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakamud%2Fnumericedittext-xamarin.android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakamud%2Fnumericedittext-xamarin.android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakamud%2Fnumericedittext-xamarin.android/lists"}