Error EditText: duplicate content after clicking character with restriction

I have an EditText with a restricted character. I allow numbers only as

A strange thing appears on Galaxy S4. It was not HTC Desire HD, HTC Desire X and ZTE Blade.

  • I am typing dddsss
  • I type in a Swedish character, for example å.
  • It is not displayed because it is not a legal character, so the content remains dddsss
  • I type a character, for example. u
  • EditText content becomes dddsssdddsssu
  • I type another character, for example. tand the content becomesdddsssdddsssudddsssut

Sometimes this happens when I also click on the backspace, so this is a button click problem.

I added android:inputType="textNoSuggestions", but that did not help.

<EditText
      android:id="@+id/comment_et"
      android:layout_width="0dp"
      android:layout_height="45dp"
      android:layout_marginRight="5dp"
      android:layout_weight="1"
      android:paddingLeft="5dp"
      android:paddingRight="5dp"
      android:background="@drawable/idea_edittext"
      android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ,0,1,2,3,4,5,6,7,8,9,*,!,@,#,$,%,^,(,),_,+,-,[,],{,},:,;,&apos;,|,\,.,/,ß,?,~,="
      android:inputType="textCapSentences|textNoSuggestions"
      android:textSize="16dp" />

Has anyone experienced this?

+4
2

, inputType EditText :

android:inputType="text|textNoSuggestions"

, , .

+1

EditText :

android:inputType="text|textNoSuggestions"

. , , "". , , , , , , , EditText, :

 private string formerText = null;
 private bool isEditLocked = false;

 editText.TextChanged += (sender, e) =>
            {
                if (!isEditLocked)
                {
                    var currentSelection = editText.SelectionStart;
                    isEditLocked = true;
                    if (formerText != null && editText.Text == formerText)
                    {
                        if (editText.Text.Length == 0)
                        {
                            editText.Text = "";
                        }
                        else
                        {
                            var lastChar = editText.Text[editText.Text.Length - 1];
                            editText.Text = editText.Text.Remove(editText.Text.Length - 1);
                            editText.Text += lastChar;
                        }
                    }
                    formerText = editText.Text;
                    editText.SetSelection(currentSelection);
                    isEditLocked = false;
                }
            };

, char EditText, , .

, Xamarin.Android, #, Java (editText.Text =... editText.setText(...) ).

, - , , 2017 .

0

Source: https://habr.com/ru/post/1538187/


All Articles