PullToRefreshListView组件的OnItemClickListener中的position下标问题

时间:2021-08-10 05:18:11
  /**
* Pass-through method for {[url=home.php?mod=space&uid=91636]@link[/url] PullToRefreshBase#getRefreshableView()
* getRefreshableView()}.
* {@link AdapterView#setOnItemClickListener(OnItemClickListener)
* setOnItemClickListener(listener)}. This is just for convenience!
*
* @param listener
* - OnItemClickListener to use
*/
public void setOnItemClickListener(final OnItemClickListener listener) {
mRefreshableView.setOnItemClickListener(listener);
if (listener == null) {
mRefreshableView.setOnItemClickListener(null);
return;
} mRefreshableView.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
listener.onItemClick(parent, view,
position - mRefreshableView.getHeaderViewsCount(), id);
}
});
}
取数据的时候下标减一

PullToRefreshListView中position为什么是从1开始的?

因为有个 header header 的位置是0,所以  item就从1开始了