2015-08-14 55 views
1

我有我的Android应用程序的列表视图,我想在列表视图的顶部做一个动画,当用户在滚动像instagram或twitter应用程序的一个。我将如何去做这件事。有没有一种方法是当用户滚动并且我正在考虑为实际动画使用frameanimation时调用的。您的活动如何使android listview刷新动画?

<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> 

然后:

+0

对不起,我刚刚发现这个http://stackoverflow.com/questions/4583484/how-to-implement-android-pull-to-refresh – user2581628

回答

2

您可以在XML文件中添加刷卡刷新布局

swipeRefresher = (SwipeRefreshLayout)findViewById(R.id.favs_refresher); 
    swipeRefresher.setOnRefreshListener(this); 

确保您的活动实现SwipeRefreshLayout.OnRefreshListener

那么你可以让使用onRefresh()方法:

@Override 
public void onRefresh() { 
    //do something 
}