当我将数据提取到ListView中时,以相同的顺序获取数据,但是如果我想基于MemberID对数据进行排序,但是我想在顶部显示最新的数据
public class AppointmentsActivity extends Activity {
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
....
adapter = new MembersAdapter (MembersActivity.this, R.layout.adapter_members, membersArrayList);
listView.setAdapter(adapter);
}
........
}
解决方法:
如果您使用Java 8开发,则可以使用lambda表达式:
Collections.sort(membersArrayList,
(m1, m2) -> (int) (m2.getMemberID() - m1.getMemberID()));