View selectedView = mListView.getSelectedView(); if(selectedView!=null){ int top = selectedView.getTop(); int bottom = selectedView.getBottom(); if(top<10&&mListView.getSelectedItemPosition()!=0){ Log.d("TAG", "##### 滚动到顶部 #####"); mListView.setScrollState(ListView.ScrollState.TOP); }else if(Math.abs(bottom-(selectedView.getHeight()*5+mListView.getDividerHeight()*5))<10&&mListView.getSelectedItemPosition()!=(totalItemCount-1)){ Log.d("TAG", "##### 滚动到底部 ######"); mListView.setScrollState(ListView.ScrollState.Bottom); }else { mListView.setScrollState(ListView.ScrollState.Default); } }
判断ListView选择的位置
最新推荐文章于 2018-11-16 16:58:33 发布