ListView addHeaderView (), addFooterView () and list of changes

addHeaderView()、addFooterView()

addHeaderView () and addFooterView () is used prior to the ListView set Adapter add or remove some elements in the list.
Mainly the following considerations:

  1. Two methods must be called before setAdapter (). If you call too addHeaderView () or addFooterView () before, during setAdapter (A), really set another adapter B, the elements of the pre-added prior to the elements A and B to the unified management.
  2. Multiple calls addHeaderView (), located behind the first insert after insertion, therefore, belongs to the end of interpolation. addFooterView () empathy.
  3. Add the head elements will squeeze the original elements in A rearwardly, i.e. using addHeaderView () added after two elements, A is originally located Adapter element position = 0, the current position may be a 2.

Change a list item

When the list has demonstrated the need to change (add, delete, etc.), the data source you want to do Add / Remove, and then call for notifyDataSetChanged adapter () method allows the adapter to refresh the list.

Guess you like

Origin www.cnblogs.com/pravez/p/12604645.html