Best way to build and handle List view with differing rows

懵懂的女人 提交于 2019-12-02 11:23:29

when you have to manage different kinds of views you should override getViewTypeCount() and getItemViewType() and you will receive a number of convertViews equals to the int returned by getViewTypeCount(). For instance, If it returns 2 you will get 2 differents convertView.

ListView is supposedly used to relieve the coders of some burden when each row has similar repetitive pattern. Yes, for slight variations getViewType is the correct choice to implement, but I see a better solution to your problem: you should create your own linearlayout if you have a lot of customization requirement. Remember that listview itself is an expensive object to create. Create a custom linearlayout is not that hard.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!