我有一個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