How does scrolling work in the Google+ Android app?

北城余情 提交于 2019-12-06 06:07:56

It's a side effect of using a recycling ListView. As new posts are scrolled in to view, the rest of the items are virtualized - basically Android guesses as to how much space the rest of the list will take up, but it doesn't actually render them so it can't be sure. As you scroll on to a big post, it assumes the rest of the list has big posts in it and therefore the list is longer.

You can get the same functionality by using the convertView parameter of getView like so:

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    View view = null;
    if(convertView == null)
    {
        view = // set your view here
    }
    else
    {
        view = convertView
    }
    // set all your properties on the view here.
    return view;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!