滚动列表视图并检测结束-android
我有一个列表视图,里面有很多项目的线性布局。现在我想在按钮上有一个imageview,说明scrolldown,直到到达scrollview的末尾,一旦到达末尾,就隐藏它自己。再次,一旦用户向上滚动,imageview应该重新出现。有人能告诉我如何检测scrollview的结尾吗??搜索了几个论坛,但他们给了listview,但我迫切需要的滚动查看只。请帮忙 您必须在BaseAdapter类中的滚动列表视图并检测结束-android,android,android-scrollview,android-scroll,android-scrollbar,Android,Android Scrollview,Android Scroll,Android Scrollbar,我有一个列表视图,里面有很多项目的线性布局。现在我想在按钮上有一个imageview,说明scrolldown,直到到达scrollview的末尾,一旦到达末尾,就隐藏它自己。再次,一旦用户向上滚动,imageview应该重新出现。有人能告诉我如何检测scrollview的结尾吗??搜索了几个论坛,但他们给了listview,但我迫切需要的滚动查看只。请帮忙 您必须在BaseAdapter类中的getView(int-position,View-convertView,ViewGroup-par
getView(int-position,View-convertView,ViewGroup-parent)
方法上检查数组列表计数
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
// Change the visibility here
if(list.size >= position)
imageView.setVisibility(View.Gone);
else
imageView.setVisibility(View.Visible);
return rowView;
}
您可以通过以下代码检测滚动的结束
if (yourListView.getLastVisiblePosition() == yourListView.getAdapter().getCount() -1 &&
yourListView.getChildAt(yourListView.getChildCount() - 1).getBottom() <= yourListView.getHeight())
{
//It is scrolled all the way down here
}
if(yourListView.getLastVisiblePosition()==yourListView.getAdapter().getCount()-1&&
yourListView.getChildAt(yourListView.getChildCount()-1).getBottom()谢谢你的回复,但是我不能完全理解你,converView和parent在这里代表什么?请你详细说明一下!