/**
* 通过pos的到item的view
*@parampos
*@paramlistView
*@return
*/
publicViewgetViewByPosition(intpos,ListView listView) {
final intfirstListItemPosition = listView.getFirstVisiblePosition();
//getChildCount() 返回的是显示在屏幕上可见的item的数量
final intlastListItemPosition = firstListItemPosition + listView.getChildCount() -1;
if(pos < firstListItemPosition || pos > lastListItemPosition) {
returnlistView.getAdapter().getView(pos, null,listView);
}else{
final intchildIndex = pos - firstListItemPosition;
returnlistView.getChildAt(childIndex);
}
}
网友评论