当我水平滑动屏幕时,为什么还会调用android swiperefreshlayout onRefresh()方法?

时间:2015-06-15 08:07:43

标签: android pull-to-refresh swiperefreshlayout

我已经实现了一个类似于刷新的Android Gmail(使用谷歌SwipeRefreshLayout类),但它非常烦人,即使我横向滑动屏幕,它调用它的onRefresh()使我很难使用。我想仅用作垂直滚动功能。提前谢谢。

XML

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

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

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:id="@+id/view1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:orientation="horizontal" >
                    </LinearLayout>
                </LinearLayout>
            </RelativeLayout>
        </android.support.v4.widget.SwipeRefreshLayout>

    </LinearLayout>

Java代码

SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);

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

   swipeLayout.setOnRefreshListener(new OnRefreshListener() {

                    @Override
                    public void onRefresh() {

                             //SOME TASK HERE
                    }
                });

0 个答案:

没有答案