【发布时间】:2013-10-11 16:06:29
【问题描述】:
当列表项不在屏幕上时,我在获取列表项的视图时遇到问题。
首先我平滑滚动到它
//locationsList is a listview
locationsList.post(new Runnable() {
@Override
public void run() {
locationsList.smoothScrollToPosition(k);
}
});
那我想做
View listItem = locationsList.getChildAt(k);
listItem.setBackgroundColor(getResources().getColor(R.color.highlight));
滚动完成后如何调用它?
【问题讨论】:
-
所以基本上你想知道滚动完成的时间?
-
getview 将在该位置可见时被调用,因此请尝试在 getview 中更改背景。
-
@Lefteris 是的,如果视图不在屏幕上,getChildAt 将返回 null
-
getView 听起来不错,我试试看。
标签: android android-listview smooth-scrolling