Android SwipeRefreshLayout通过拉动禁用刷新

时间:2015-05-30 12:20:21

标签: android google-maps android-activity android-progressbar swiperefreshlayout

我想在SwipeRefreshLayout中显示一个谷歌地图,以便在刷新标记时获得花哨的进度圈。我注意到你无法再向上移动地图,因为它触发了SwipeRefreshLayout。我已经尝试过使用setDistanceToTriggerSync()并且在拉动时它不再刷新,但我仍然无法向上移动。我正在使用的代码:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

    </android.support.v4.widget.SwipeRefreshLayout>

    <fragment
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment" />

</LinearLayout>

2 个答案:

答案 0 :(得分:0)

如果loading circle需要SwipeRefreshLayout,请让您在SwipeRefreshLayout标记内进行映射,并使用FrameLayout作为父视图组。

您可以按如下方式尝试代码:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent">

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

    <fragment
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment" />

    </android.support.v4.widget.SwipeRefreshLayout>

</FrameLayout>

答案 1 :(得分:0)

要禁用手势和进度动画,  在视图上调用List<String> kennelIdsToloopThrough = getAllKennelIds(); for (int i = 0; i < kennelIdsToloopThrough.size(); i++) { //create list with all dogs in kennels allDogsInKennel = kennel.getDogsList(); //pass list and remove dog from kennel if status = released removeDogFromKennel(i,allDogsInKennel); //save the changes to the DB kennelRepository.save(kennel); }

setEnabled(false)