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 :
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.
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;
}