如何在ArrayAdapter列表的开头添加对象? [英] How to add object at the beginning of the list in ArrayAdapter?

查看:51
本文介绍了如何在ArrayAdapter列表的开头添加对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ArrayAdapter具有方法add(T object),该方法将对象添加到列表的末尾. 有没有一种方法可以在列表的开头添加对象?

ArrayAdapter has method add(T object) which add an object at the end of a list. Is there a way to add object at the beginning of the list?

推荐答案

您可以使用

You can use the .insert(T object, int index) method for this, using 0 as an index:

yourAdapter.insert(object, 0);

这篇关于如何在ArrayAdapter列表的开头添加对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆