Android的滚动视图onScrollChanged [英] Android scrollview onScrollChanged

查看:221
本文介绍了Android的滚动视图onScrollChanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动视图在我的文本视图一个固定的内容。当用户滚动到某个位置,我想开始一个活动或触发吐司

I have a fixed content in my text view inside a scroll view. When the user scrolls to a certain position, I would like to start an activity or trigger a Toast.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 android:id="@+id/scroller">
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <TextView android:layout_width="fill_parent" android:id="@+id/story"
   android:layout_height="wrap_content" android:text="@string/lorem"
   android:gravity="fill" />
 </LinearLayout>
</ScrollView>

我的问题是在实施保护的方法 onScrollChanged 找出滚动视图的位置。

My problem is in implementing the protected method onScrollChanged to find out the position of the scroll view.

我已经找到<一href="http://stackoverflow.com/questions/3948934/synchronise-scrollview-scroll-positions-android">this答案是有更简单的解决了这个,而不是宣布一个接口,在乘坐滚动型等看到我张贴的链接?

I have found this answer, is there an easier solution to this rather than declaring an interface, over ride the scrollview etc as seen on the link I posted?

推荐答案

没有。

滚动型不提供侦听滚动事件,甚至一个方法来检查多远下来的用户滚动,所以你必须做的是建议的链接。

ScrollView doesn't provide a listener for scroll events or even a way to check how far down the user has scrolled, so you have to do what is suggested by the link.

这篇关于Android的滚动视图onScrollChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆