Code example for ListAdapter

Methods: getCountregisterDataSetObserver

1
		 
		this.baseAdapter = baseAdapter;
		this.context = context;
		calculateHeadersAndFooters(); 
		baseObserver = new ParentAdapterObserver(this);
		baseAdapter.registerDataSetObserver(baseObserver);
	} 
	 
	public void update(ListAdapter baseAdapter) {
		this.baseAdapter.unregisterDataSetObserver(baseObserver);
		this.baseAdapter = baseAdapter;
		this.baseAdapter.registerDataSetObserver(baseObserver);
		this.notifyDataSetChanged();
	} 
 
	@Override 
	public void notifyDataSetChanged() { 
		super.notifyDataSetChanged(); 
		calculateHeadersAndFooters(); 
	} 
	 
	protected void calculateHeadersAndFooters() { 
		long itemId = STARTING_ITEM_ID;
		dataItems = new ArrayList<GroupedAdapter.GroupedDataItem>();
		Object lastGroupId = null;
		Object currentGroupId = null;
		 
		for (int i=0;i<baseAdapter.getCount();i++) {
			currentGroupId = groupIdFunction(baseAdapter.getItem(i),i);
			 
			if (lastGroupId == null && hasHeader) {
				dataItems.add(new GroupedDataItem(GroupedDataItemType.HEADER,currentGroupId, itemId));
				itemId++;