【发布时间】:2013-03-24 10:41:10
【问题描述】:
我有一个 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
android:id="@+id/CommentsListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/AddCommentLayout"
android:stackFromBottom="true" >
</ListView>
我想要做的是在用户滚动到顶部时加载旧的 cmets。
感谢您的帮助。
【问题讨论】: