Android ListView 刷新单行 [英] Android ListView Refresh Single Row

查看:30
本文介绍了Android ListView 刷新单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在获得 ListView 的单行数据后,我想更新该单行.

After I have gotten the data for a single row of a ListView, I want to update that single row.

目前我正在使用 notifyDataSetChanged(); 但这使得 View 反应非常缓慢.还有其他解决方案吗?

Currently I am using notifyDataSetChanged(); but that makes the View react very slowly. Are there any other solutions?

推荐答案

一种选择是直接操作 ListView.首先检查更新行的索引是否在 getFirstVisiblePosition()getLastVisiblePosition() 之间,这两个为您提供适配器中可见的第一个和最后一个位置屏幕.然后您可以使用 getChildAt(int index) 获取行 View 并更改它.

One option is to manipulate the ListView directly. First check if the index of the updated row is between getFirstVisiblePosition() and getLastVisiblePosition(), these two give you the first and last positions in the adapter that are visible on the screen. Then you can get the row View with getChildAt(int index) and change it.

这篇关于Android ListView 刷新单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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