I want an ediText field in my app to respond to onTextChange events so a method is called when the text changes. I am using dot42 to make the app but could only find tutorials available in Java.
Asked
Active
Viewed 620 times
0
-
1did you try anything , at least [Google](http://www.google.com) – Hussain Akhtar Wahid 'Ghouri' Nov 14 '13 at 12:57
-
yes i did. but didn't help. if know how to do it please share. – desolator Nov 14 '13 at 12:58
-
1[link1](http://stackoverflow.com/questions/7432083/how-to-use-edittext-ontextchanged-event-when-i-press-the-number) , and [link2](https://www.google.co.in/search?q=ontextchange+event+in+android&oq=ontextchange+event+in+android&aqs=chrome..69i57j0l5.6387j0j7&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8) – Hussain Akhtar Wahid 'Ghouri' Nov 14 '13 at 12:59
-
please read the question. I want to do it in dot42 not by java. – desolator Nov 14 '13 at 13:02
2 Answers
4
This would be a minimal implementation. I hope it helps you see a pattern in the difference between Java and C# - it is really trivial.
[Activity]
public class MainActivity : Activity, Android.Text.ITextWatcher
{
protected override void OnCreate(Bundle savedInstance)
{
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainLayout);
EditText editText = FindViewById<EditText>(R.Ids.status);
editText.AddTextChangedListener(this);
}
public void AfterTextChanged(Android.Text.IEditable s)
{
throw new NotImplementedException();
}
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)
{
throw new NotImplementedException();
}
}
The interface implementation is generated by Visual Studio.

Frank Rem
- 3,632
- 2
- 25
- 37
-
If it were possible I would give you 1,000 points... I'm from hours around this issue – Blasco73 Jul 25 '14 at 16:53
1
In Java you'd do it by implementing a TextWatcher interface. Dot42 documentation says that
AddTextChangedListener(ITextWatcher watcher)
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.`
So implement ITextWatcher, do something in AfterTextChanged
and you're OK.

Axarydax
- 16,353
- 21
- 92
- 151
-
I read the documentation but didn't help. Please share sample code if you have . – desolator Nov 14 '13 at 13:06
-
I don't have any sample code. Did you try to do as I suggested? Did you call myTextView.AddTextChangedListener with the custom ITextWatcher? – Axarydax Nov 14 '13 at 13:30