我想将 ListView 的顺序更改为最近添加的项目位于 ListView 的顶部,旧的项目位于最后
我从 sqlite 获取数据,然后将它们填充到名为 reports_items_obj 的对象的数组列表中 我使用自定义adpater来查看
ListView list_messages = (ListView) findViewById(R.id.list);
Report_adapter adapter = new Report_adapter(getApplicationContext(), reports_items_obj);
list_messages.setAdapter(adapter);
xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</ListView>
</LinearLayout>
最佳答案
ListView 的顺序基于数组列表或游标中项目的顺序,或者来自将填充到 ListView 中的数据存储位置的顺序。所以尝试改变arraylist的顺序。
关于android-更改列表的排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25134948/