'RecyclerView editText text change show another field in android
I have recyclerView where i have added a editText. But when I type text to one edittext, text shows another edittext too. Here is the image..
Above image, I type 100 to other item, but it also shows in Settlements
Here is my adapter:
public class AdapterSectionRecycler extends SectionRecyclerViewAdapter<SectionHeader, Child, SectionViewHolder, ChildViewHolder> { Context context; private final OnItemClickListener listener; public interface OnItemClickListener { void onItemClick(Child child,Boolean isChecked); } public AdapterSectionRecycler(Context context, List<SectionHeader> sectionItemList,OnItemClickListener listener) { super(context, sectionItemList); this.context = context; this.listener = listener; } @Override public SectionViewHolder onCreateSectionViewHolder(ViewGroup sectionViewGroup, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.section_item, sectionViewGroup, false); return new SectionViewHolder(view); } @Override public ChildViewHolder onCreateChildViewHolder(ViewGroup childViewGroup, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.item_layout, childViewGroup, false); return new ChildViewHolder(view); } @Override public void onBindSectionViewHolder(SectionViewHolder sectionViewHolder, int i, SectionHeader sectionHeader) { Log.e("name section--",sectionHeader.getSectionText()); sectionViewHolder.name.setText(sectionHeader.getSectionText()); } @Override public void onBindChildViewHolder(ChildViewHolder childViewHolder, int i, int i1, Child child) { childViewHolder.chk_answer.setText(child.getAnswerName()); childViewHolder.tv_surveyAnswerId.setText(String.valueOf(child.getAnswerId())); childViewHolder.chk_answer.setChecked(false); childViewHolder.etPercentage.setImeOptions(EditorInfo.IME_ACTION_DONE); childViewHolder.etsl.setVisibility(View.GONE); childViewHolder.chk_answer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { listener.onItemClick(child,true); }else{ listener.onItemClick(child,false); } } }); childViewHolder.etPercentage.addTextChangedListener(new TextWatcher() { @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) { } }); } }
Here is my Child View holder
public class ChildViewHolder extends RecyclerView.ViewHolder {
CheckBox chk_answer;
EditText etPercentage;
EditText etsl;
TextView tv_surveyAnswerId;
public ChildViewHolder(View itemView) {
super(itemView);
chk_answer = (CheckBox) itemView.findViewById(R.id.chk_answer);
etPercentage = (EditText) itemView.findViewById(R.id.etPercentage);
etsl = (EditText) itemView.findViewById(R.id.etsl);
tv_surveyAnswerId = (TextView) itemView.findViewById(R.id.tv_surveyAnswerId);
}
}
I call from activity:
AdapterSectionRecycler adapterSectionRecycler = new AdapterSectionRecycler(this, sections, new AdapterSectionRecycler.OnItemClickListener() {
@Override
public void onItemClick(Child child, Boolean isChecked) {
}
});
recyclerView_land_conversion.setAdapter(adapterSectionRecycler);
What is the wrong with my code? Please help me..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|