I'm trying to refresh specific item in RecyclerView
.
Story: Whenever user clicks on item, it shows AlertDialog
. User can type some text by clicking ok button. I want to show this text in this item and show invisible ImageView
- declared in XML and adapter ViewHolder
-
I used this function in AlertDialog
Positive Button to update the item:
private void updateListItem(int position) {
View view = layoutManager.findViewByPosition(position);
ImageView medicineSelected = (ImageView) view.findViewById(R.id.medicine_selected);
medicineSelected.setVisibility(View.VISIBLE);
TextView orderQuantity = (TextView) view.findViewById(R.id.order_quantity);
orderQuantity.setVisibility(View.VISIBLE);
orderQuantity.setText(quantity + " packet added!");
medicinesArrayAdapter.notifyItemChanged(position);
}
But this code not only changes the itemView at passed position, but also changes some of other itemView(s) as well!
How should I change specific itemView correctly by clicking on it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…