Adapter中 getItemViewType() ,getViewTypeCount() 中的作用?
当item中需要显示不同类型的item时。 在getview()中处理这种逻辑调用 自己实现的
getItemViewType() 来return不同的View item;
Different list items’ layouts
Let’s move to the “more complicated” example. How about to add separator somewhere to the list.
You should do the following:
- Override getViewTypeCount() – return how many different view layouts you have
- Override getItemViewType(int) – return correct view type id by position
- Create correct convertView (depending on view item type) in getView