AutocompleteTextView with TextWatcher

BSBS2 1 Reputation point

I am trying to add TextWatcher to AutoCompleteTextView. In Activity I have Extends with Android.Text.ITextWatcher and implement interface methods. The problem is that, String helperString is not changing. I also added autocomplete.AddTextChangedListener(this); to AutoCompleteTextView. What am i doing wrong?

public void AfterTextChanged(IEditable s)
            helperText = this.FindViewById<TextView>(Resource.Id.helper_text);
            String helperString = s.ToString().ToUpper();
            Console.WriteLine(helperString + "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
            helperText.Text = (s.ToString().ToUpper());


        public void BeforeTextChanged(Java.Lang.ICharSequence s, int start, int count, int after)
            throw new NotImplementedException();

        public void OnTextChanged(Java.Lang.ICharSequence s, int start, int before, int count)
            String inputValue = s.ToString();
            Toast.MakeText(this, inputValue, ToastLength.Short).Show();
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,014 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. cristopheB 526 Reputation points
    0 comments No comments

  2. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,736 Reputation points


    Welcome to Microsoft Q&A!

    Stop Setting text on AutoCompleteTextView in ITextWatcher interface , it will trigger the method (AfterTextChanged , BeforeTextChanged , OnTextChanged ) So this will lead to a infinite loop .

    If you just want uppercase words when inputing , just need to set android:inputType="textCapCharacters" on AutoCompleteTextView in xml .

    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