Reputation: 19
I'm currently developing for Android
using C#
and Xamarin
.
I have an EditText
box within my app where the user can input information. How can I add a listener that will see if the user is actually typing in it? The reason I need this is to link it to analytics, so I can see how many users actually type information.
Thanks!
Upvotes: 0
Views: 4138
Reputation: 74209
Implement the ITextWatcher
on your Activity
, Fragment
subclass or create a new Java.Lang.Object
class:
public class TextWatcher : Java.Lang.Object, ITextWatcher
{
public void AfterTextChanged(IEditable s)
{
//
}
public void BeforeTextChanged(ICharSequence s, int start, int count, int after)
{
//
}
public void OnTextChanged(ICharSequence s, int start, int before, int count)
{
//
}
}
Add the listener to your EditText
instance:
editText.AddTextChangedListener(new TextWatcher());
Upvotes: 3
Reputation: 993
editText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
textView.Text = e.Text.ToString ();
};
Is what I believe you are looking for, more information here
Upvotes: 11
Reputation: 351
add text change listener and in afterTextChanged Method, save the device's mac address to the server . Because MAC address is always unique
Field1.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
});
you can count number of users with the help of number of mac addresses
Upvotes: 0