简体   繁体   English

Android:修改Listview上的项目

[英]Android: modify item on Listview

I have a ListView . 我有一个ListView

I'm using an ArrayAdapter and I'd like to: when the user clicks any item on the list, its LinearLayout (is just a content for x information) fades out and is substituted by other LinearLayout (with y information) which fades in. 我正在使用ArrayAdapter并且我想:当用户单击列表中的任何项目时,其LinearLayout (仅仅是x信息的内容)淡出并被其他LinearLayout (带有y信息)替换为淡入淡出。

However, I do not know how to apply this on my ArrayAdapter . 但是,我不知道如何在我的ArrayAdapter上应用它。 I've searched for a while but I'm not understanding how can I access a single item from the Adapter and make it's children fade out or fade in. 我已经搜索了一段时间,但我不明白如何从Adapter访问单个项目并让它的孩子淡出或淡入。

Any help would be very appreciated. 任何帮助将非常感激。 Thank you very much for your time. 非常感谢您的宝贵时间。

In general - adapters do not hold items the role of adapter is to get data model, and to produce item views when ie list view needs them. 通常 - 适配器不保存项,适配器的作用是获取数据模型,并在列表视图需要时生成项视图。

The main concept of replacing item is to replace data inside the adapter and call notifyDataSetChanged(); 替换项的主要概念是替换适配器内的数据并调用notifyDataSetChanged(); - thats all. - 就这样。

I don't like ArrayAdapter as it's aimed for very simple scenarios. 我不喜欢ArrayAdapter,因为它针对非常简单的场景。 Usually I just create my own Adapter class extending BaseAdapter (just 4 methods to implement). 通常我只是创建自己的Adapter类扩展BaseAdapter(只有4种方法可以实现)。

The transitions of items on ListView are described here: Adding animation to a List View in Android 此处描述了ListView上项目的转换: 在Android中向列表视图添加动画

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM