I am trying to update a specific item in a RecyclerView .
History: When the user clicks on an element, it shows AlertDialog . The user can enter the text by clicking the "OK" button. I want to show this text in this element and show an invisible ImageView - declared in XML and ViewHolder adapter -
I used this function in AlertDialog Positive Button to update an element:
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 in the passed position, but also changes some other itemView elements!
How can I correctly modify a specific ItemView by clicking on it?
android android-recyclerview recycler-adapter android-adapter
Elgendy Sep 08 '15 at 12:05 2015-09-08 12:05
source share