Reputation: 82
I am trying to get commas as the decimal separator for the numeric keyboard on a Samsung Galaxy Note II. I've tested my app on other devices (Moto X, rooted Samsung GS4) and their numpads have the correct separator if I change the language from the device's system settings. Is this feature not possible on Samsung's software?
Edit/Clarification: Is there a way to have the correct decimal separator without telling my users to download a different keyboard or creating my own input UI?
Upvotes: 1
Views: 3469
Reputation: 3370
I had a custom Entry, called LineEntry, this is my solution for the Samsumg devices to change the numeric keyboard.
[assembly: ExportRenderer(typeof(LineEntry), typeof(CustomEntryRenderer))]
namespace myApp.Droid.Services
{
public class CustomEntryRenderer : EntryRenderer
{
public CustomEntryRenderer(Android.Content.Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || this.Element == null)
{
return;
}
//ClassNumber | NumberFlagDecimal | NumberFlagSigned
if (this.Control.InputType == Keyboard.Numeric.ToInputType())
{
// this.Control.KeyListener = Android.Text.Method.DigitsKeyListener.GetInstance(Resources.Configuration.Locale, true, true);
this.Control.KeyListener = Android.Text.Method.DigitsKeyListener.GetInstance(string.Format("1234567890{0}", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
this.Control.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberFlagDecimal;
}
}
}
}
Upvotes: 0
Reputation: 3974
I experience the same problem, even now 2 years after you asked the question. You better install the Google keyboard:
https://play.google.com/store/apps/details?id=com.google.android.inputmethod.latin&hl=no
If you need to distribute the APK using your internal device management system the APK can be downloaded from here:
https://www.apkmirror.com/apk/google-inc/google-keyboard/
Unfortunately (or not if you think security wise) there is no programmatic way for your app to decide which keyboard to use. Best option is to have a configuration page in your app telling the users how and why they should change their default keyboard.
You can use this code to open a keyboard settings dialog:
public void showInputMethodPicker() {
InputMethodManager imeManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
if (imeManager != null) {
imeManager.showInputMethodPicker();
}
}
Upvotes: 0