我有一个列表视图,其中包含许多项目的线性布局。现在我希望在按钮上有一个imageview,说明滚动到达滚动视图的结尾,一旦到达结束就隐藏它自己。用户向上滚动后,将再次出现imageview。任何人都可以告诉如何检测scrollview结束?搜索了几个论坛,但他们已经给了listview,但我非常需要滚动视图。请帮忙!
答案 0 :(得分:1)
您可以通过以下代码检测滚动结束
if (yourListView.getLastVisiblePosition() == yourListView.getAdapter().getCount() -1 &&
yourListView.getChildAt(yourListView.getChildCount() - 1).getBottom() <= yourListView.getHeight())
{
//It is scrolled all the way down here
}
希望它有所帮助。
答案 1 :(得分:0)
您必须检查BaseAdapter类
中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;
}