0

I have a listView with an overriden ArrayAdapter. In contains an ArrayList. The object Order can have following states:

  • NEW
  • READ
  • ACCEPTED
  • CANCELLED

Depending on the state of the order I inflate a different Layout and fill it with the values in the getView method and return as View. Orders are being synchronized with the server every minute. This works all like it should. If a new Order comes, it is inserted into the ArrayList and NotifyDataSetChange is called and the listView is updated. However, for some reason, some of the existing items in the list change their layout (the state is not changed, checked in the logs). This happens everytime NotifyDataSetChanged is called and I don't see any logic or anything in this behavior. Does anyone know why is this happening?

Thanks, Filip

Filip Majernik
  • 7,700
  • 13
  • 45
  • 53
  • Are you using getViewTypeCount()? See http://stackoverflow.com/questions/4777272/android-listview-with-different-layout-for-each-row – ciscogambo Oct 06 '11 at 20:54
  • I got it working. I think the problem was that I extended from the ArrayAdapter and it receives the View resource ID for the ROW view in the constructor. This is than given to the getView method. I was working with some tutorial and the convertView was tested there if it's NULL. If it was I inflated a new layout. Than I filled it with my values. If not, I just filled the convertView with the values. I supposed if the convertView wasn't null, it contained the inflated layout passed to the constructor of the CustomArrayAdapter and therefore changed the layout of the rows. Can I be right? – Filip Majernik Oct 07 '11 at 09:48

1 Answers1

0

I got it working. I think the problem was that I extended from the ArrayAdapter and it receives the View resource ID for the ROW view in the constructor. This is than given to the getView method. I was working with some tutorial and the convertView was tested there if it's NULL. If it was I inflated a new layout. Than I filled it with my values. If not, I just filled the convertView with the values. I supposed if the convertView wasn't null, it contained the inflated layout passed to the constructor of the CustomArrayAdapter and therefore changed the layout of the rows. Can I be right?

Filip Majernik
  • 7,700
  • 13
  • 45
  • 53