我有一个listView,我想添加新项目到列表视图的顶部,但我不希望列表视图滚动其内容。我希望用户在添加新项目之前查看与他相同的项目。Android ListView将项目添加到顶部,无列表视图滚动
这是我如何增加新项目的ListView:
this.commentsListViewAdapter.addRangeToTop(comments);
this.commentsListViewAdapter.notifyDataSetChanged();
,这是addRangeToTop
方法:
public void addRangeToTop(ArrayList<Comment> comments)
{
for (Comment comment : comments)
{
this.insert(comment, 0);
}
}
这是我的ListView:
<ListView
android:id="@+id/CommentsListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/AddCommentLayout"
android:stackFromBottom="true" >
</ListView>
我想什么做的是当用户滚动到顶部时加载旧评论。
谢谢你的帮助。
非常感谢! – sirvon 2014-10-06 23:55:54
好的解决方法,谢谢! – 2015-03-19 15:03:47