-1

I want to Implement AddTextChangedListener to AutoCompleteTextView using Android.Text.ITextWatcher But I can't find any way on how to implement in Xamarin.

I am using BigData so every Single Character add in AutoCompleteTextView i want to call server to check the data. So I want to add onTextChanged, beforeTextChanged and afterTextChanged for my AutoCompleteTextView.

In pure Android I am using below way

txtSearch.addTextChangedListener(new TextWatcher() {
                                @Override
                                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                                }

                                @Override
                                public void onTextChanged(CharSequence s, int start, int before, int count) {
                                    String newText = txtSearch.getText().toString();
                                    new getJsonData().execute(newText);
                                }

                                @Override
                                public void afterTextChanged(Editable s) {

                                }
                            });

Any Help be Highly Appreciated.

Update :

enter image description here

See the Upper ScreenShot If user write something on Medical Store AutoCompleteTextView and select the value from Suggestion which is change every time when user write single new character. Then I want to set it Address if user select some value from data.

Harshad Pansuriya
  • 17,218
  • 7
  • 58
  • 86

1 Answers1

0

I got the Solution.

In my Activity I have Extends with Android.Text.ITextWatcher and Implement Interface Method it will Create like below way

public void AfterTextChanged(IEditable s)
        {

        }

public void BeforeTextChanged(ICharSequence s, int start, int count, int after)
        {

        }

public async void OnTextChanged(ICharSequence s, int start, int before, int count)
        {
            string newText = autoCompleteTextView.Text;
            var suggestionData = await PrescriptionServices.GetFilterData(newText);

            adapter = new ArrayAdapter(this, Resource.Layout.row_org, suggestionData);
            autoCompleteTextView.Adapter = adapter;

        }
Harshad Pansuriya
  • 17,218
  • 7
  • 58
  • 86
  • seems you didnt get what i meant, take a look [here](http://androidxref.com/7.0.0_r1/xref/frameworks/base/core/java/android/widget/AutoCompleteTextView.java#856), as you can see `ACTV` already has `TextWatcher` (called `MyWatcher`), just analize this source code and you will know how to use `ACTV` correctly – pskink Nov 18 '16 at 13:35