0

I have an adapter for a recyclerview. I've implemented the onClick like this:

    public interface OnItemClickListener {
    void onItemClick(View itemView, int position);
}
private OnItemClickListener listener;
public void setOnItemClickListener(OnItemClickListener listener) {
    this.listener = listener;
}

and in the ViewHolder:

this.sendBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onItemClick(sendBtn, getLayoutPosition());
                }
            }
        });

Then in my fragment I get to implement it. So my problem is that I'd like to do the same with an EditText(new TextWatcher), but I'm getting quite confused on how to actually proceed.

Any help would be highly appreciated.

  • what are you trying to do? do you want to call `onItemClick` when user puts a character into `EditText`? that's sounds a bit weird – Gennadii Saprykin Aug 05 '15 at 23:50
  • no, I need to implement a "user is typing" kind of thing. The TextWatcher overrides 3 methods, not just one like the onClickListener and that's what is confusing me. The onClick() was just a way for me to describe my problem. – Ioannis Panteleakis Aug 06 '15 at 02:57
  • `onTextChanged` callback should be fine for this purpose. It is called when user is actually typing – Gennadii Saprykin Aug 06 '15 at 03:00
  • Thank you Gennadii, but I'd like to use the other methods as well when I override it in my fragment. I was following something like that for the detection of typing: http://stackoverflow.com/a/27306704/1899334 – Ioannis Panteleakis Aug 06 '15 at 03:14

0 Answers0