0

I have an ArrayAdapter that is bound to an ArrayList<MyClass>

There is a lot of logic inside MyClass including changing certain properties of MyClass objects that require a refresh in view. Once such a change is detected inside MyClass object, I would like to call the associated ArrayAdapter.notifyDataSetChanged().

However, the items of MyClass don't automatically store a reference to the adapter, while the adapter stores a reference to the ArrayList. Is there an easy way to solve this problem?

Don Chakkappan
  • 7,397
  • 5
  • 44
  • 59
dowjones123
  • 3,695
  • 5
  • 40
  • 83

2 Answers2

0

You can't reload a single row, but instead you can get the requested view and make changes on it directly by calling yourListView.getChildAt(int VisiblePosition); where the visiblePostion is the position in the ListView minus yourListView.getFirstVisiblePosition().

Like this :

View v = listViewItems.getChildAt(position - 
        listViewItems.getFirstVisiblePosition());
v.setBackgroundColor(Color.GREEN);

Answer by Driss Bounouar

Community
  • 1
  • 1
Neji
  • 6,591
  • 5
  • 43
  • 66
0

Please create a arrayadapter and apply your change in single item

Rohit Heera
  • 2,709
  • 2
  • 21
  • 31