Xamarin android setting language for decimal field coma or dot ?

cristopheB 551 Reputation points
2021-06-09T07:54:05.123+00:00

Hello,

we have an app in c# xamarin android
in this app, we need to add an decimal field

all works but my colleague has his device to an other settings has me.
Me i have my device in language french suisse, when i enter 10.25 and save inside sqllite and edit again its works fine.

my colleague is other language and when we enter for example -> 10,25 inside the database sql lite
when he edit this value the result is 1025 ... the amount is x 100 !

How we can solve this problem ?
any idea

thanks for all

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,336 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 74,491 Reputation points Microsoft Vendor
    2021-06-10T05:46:46.633+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("fr-Fr");

    but i don't know if i need to add this on each activity / fragment ?

    Yes, it just worked in current activity / fragment. If you want to keep the French language, you have to add in your every resumed of activities. Or you can add a base activity like this thread:
    https://stackoverflow.com/a/32994325/10627299

    Then other activity could extend this base activity.

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. cristopheB 551 Reputation points
    2021-06-09T16:42:05.213+00:00

    Hello,
    i've add this on my fragment and it's seems to work ..

    System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("fr-Fr");

    but i don't know if i need to add this on each activity / fragment ?

    any comment or suggestion would be appreciated

    thanks

    0 comments No comments

  2. cristopheB 551 Reputation points
    2021-06-14T09:04:17.88+00:00

    Hello,
    thanks again for your comment leon lu..

    i've created a baseactivity and all activity heride from this
    Seems to work

    thanks for all

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.