I have a listview for my android app and I want to make an animation at the top of the list view when the user over scrolls like one the one for the instagram or twitter app. How would I go about this. Is there a method that is called when the user over scrolls and I was thinking about using a frameanimation for the actually animation.
Asked
Active
Viewed 274 times
1
-
Sorry I just found this http://stackoverflow.com/questions/4583484/how-to-implement-android-pull-to-refresh – user2581628 Aug 14 '15 at 01:32
1 Answers
2
You can add a swipe refresh layout on your xml file:
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/favs_refresher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ListView
android:id="@+id/favs_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</android.support.v4.widget.SwipeRefreshLayout>
Then on your activity:
swipeRefresher = (SwipeRefreshLayout)findViewById(R.id.favs_refresher);
swipeRefresher.setOnRefreshListener(this);
Be sure that your activity implements SwipeRefreshLayout.OnRefreshListener
then you can make use of the onRefresh()
method:
@Override
public void onRefresh() {
//do something
}

MetaSnarf
- 5,857
- 3
- 25
- 41