gpt4 book ai didi

android - 可使用 TextChangedListener 的引用进行编辑

转载 作者:行者123 更新时间:2023-11-30 03:03:30 25 4
gpt4 key购买 nike

在 Xamarin 中,我可以为 EditText 对象的 TextChangedListener 编写一些代码吗?

这是我目前所拥有的:

public class InputTextWatcher
{
public void afterTextChanged (Editable s)
{

}

public void beforeTextChanged (CharSequence s, int start, int count, int after)
{

}

public void onTextChanged (CharSequence s, int start, int before, int count)
{

}
}

这是我遇到的错误:

Error CS0246: The type or namespace name 'Editable' could not be found (are you missing a using directive or an assembly reference?)

最佳答案

您将需要实现 ITextWatcher:

using Android.Text;

public class InputTextWatcher : : Java.Lang.Object, ITextWatcher
{
public void AfterTextChanged(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 ();
}
}

您还应该考虑改用事件处理程序:

        editText.BeforeTextChanged += HandleBeforeTextChanged;

// or
editText.TextChanged += (sender, e) =>
{

};
}

void HandleBeforeTextChanged (object sender, TextChangedEventArgs e)
{

}

关于android - 可使用 TextChangedListener 的引用进行编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22191925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com