listview局部刷新关键逻辑代码:在activity中
/** * listview局部更新 */ private void updateListView(int position){ int firstVisiblePosition = mListView.getFirstVisiblePosition(); int lastVisiblePosition = mListView.getLastVisiblePosition(); if(position>=firstVisiblePosition && position<=lastVisiblePosition){ View view = mListView.getChildAt(position+1);//如果在listview中加了头部position需要加1,否则不需要 RobInfo mRobInfo = robData.get(position); if(view.getTag() instanceof viewHolder){ viewHolder vh = (viewHolder)view.getTag(); //更新该item } } }
时间: 2024-12-26 11:31:04