刷新布局时不会显示刷新图标

时间:2018-08-26 11:03:53

标签: android swiperefreshlayout

我正在尝试使用SwipeRefreshLayout,如下图所示。但是当我运行该应用程序并且最初随附的RecyclerView中没有数据时, 滑动时,我不显示刷新图标。尽管我setRefreshing(true)如下代码所示

请让我知道为什么在滑动图标时不显示滑动图标。

代码

this.mSwipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mSwipeToRefresh.setEnabled(true);
            mSwipeToRefresh.setRefreshing(true);
            startIntentService(TwitterTrendsAPIService.class);
        }
    });

布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.pc_amr.twittertrendsnearlocation.ActMain">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/actMainTextViewURLLabel"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="URL: " />

    <EditText
        android:id="@+id/actMainEditTextURLContents"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:hint="Please Enter Your URL" />
</LinearLayout>

<Button
    android:id="@+id/actMainButtonFetchURL"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Fetch URL" />

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

    <android.support.v7.widget.RecyclerView
        android:id="@+id/actMainRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:scrollbars="vertical" />

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

</LinearLayout>

0 个答案:

没有答案