I want to know how to get position of Edit Text from Recycler View adapter.I used Card View with in that horizontal Linear Layout has three view TextView,EditText view and
Assume you use the following CustomViewHolder
public static class CustomViewHolder extends RecyclerView.ViewHolder {
private TextView textView;
private TextView textView2;
private EditText editText;
private int position;
public CustomViewHolder (View view) {
super(view);
textView = (TextView) view.findViewById(R.id.text_view);
textView2 = (TextView) view.findViewById(R.id.text_view2);
editText = (EditText) view.findViewById(R.id.edit_text);
editText.addTextChangedListener(new CustomWatcher(this));
}
}
and use the following CustomWatcher
public static class CustomWatcher implements TextWatcher {
private int CustomViewHolder holder;
public CustomWatcher(CustomViewHolder holder){
this.holder = holder;
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
public int getPosition(){
return holder.position;
}
}
Then, in your onBindViewHolder
@Override
public void onBindViewHolder(final CustomViewHolder holder, final int position) {
holder.position = position;
}