Android 滚动视图 onScrollChanged [英] Android scrollview onScrollChanged
问题描述
我在滚动视图中的文本视图中有固定的内容.当用户滚动到某个位置时,我想开始一个活动或触发一个Toast
.
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.
我找到了 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 不提供滚动事件的侦听器,甚至不提供检查用户向下滚动多远的方法,因此您必须按照链接的建议进行操作.
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屋!