Android:GridView Pull-To-Refresh - 覆盖动画?

时间:2015-01-04 05:16:27

标签: java android gridview pull-to-refresh swiperefreshlayout

所以我使用android.support.v4.widget.SwipeRefreshLayout在我的GridView上实现了Pull-to-Refresh,它运行良好。但是当向下拖动手指时,只播放动画并且播放“GridView”正在下拉动画“动画”。在刷新时不会发生这种情况。 GridView在更新时保持不变。如何覆盖这个动画方法并添加一个GridView动作,它清楚地显示了GridView被手指移动拉下来的动画? (类似于facebook,Instagram&刷新)

也可能会在顶部显示一条消息,说明'刷新'

我的代码到目前为止。

XML:

<RelativeLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ECECEC"
    android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="@dimen/feed_item_margin"
            android:layout_marginRight="@dimen/feed_item_margin"
            android:layout_marginTop="@dimen/feed_item_margin"
            android:orientation="vertical"
            android:paddingBottom="@dimen/feed_item_padding_top_bottom"
            android:paddingTop="@dimen/feed_item_padding_top_bottom" >

               <android.support.v4.widget.SwipeRefreshLayout
                  android:id="@+id/swipe_container"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent" >

                <GridView
                    android:id="@+id/grid"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_alignParentBottom="true"
                    android:columnWidth="100dp"
                    android:gravity="center"
                    android:numColumns="1"
                    android:stretchMode="columnWidth"
                    android:verticalSpacing="10dp" />
            </android.support.v4.widget.SwipeRefreshLayout>
        </LinearLayout>
    </RelativeLayout>

代码:

swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
        swipeLayout.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh() {
                //my update process
                RequestParams params = new RequestParams();
                params.put("req", "dataReqAndroid");
                invokeWS(params);
            }
        });
        swipeLayout.setColorScheme(android.R.color.holo_blue_bright, 
                android.R.color.holo_green_light, 
                android.R.color.holo_orange_light, 
                android.R.color.holo_red_light);

0 个答案:

没有答案