Reputation: 14791
I am developing an Android app. I am using listview together with SwipefreshLayout. But when I refresh list view using SwipefreshLayout , the loading circle is never hidden back. I am using it in fragment.
This is layout file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- place your view here -->
<ListView
android:dividerHeight="@dimen/list_item_divider_height"
android:padding="@dimen/list_padding"
android:divider="@color/whitesmoke"
android:id="@+id/listview_podcast_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:layout_below="@+id/swipe_refresh_layout"
android:textSize="17dp"
android:textStyle="bold"
android:textColor="@color/black"
android:textAlignment="center"
android:id="@+id/tf_no_records"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
This is how I am using it in fragment
public class PodcastListFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
// property variables here
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
.
.
.
refresher = (SwipeRefreshLayout)view.findViewById(R.id.swipe_refresh_layout);
refresher.setOnRefreshListener(this);
return view;
}
@Override
public void onRefresh() {
refreshListView();
}
}
.
.
.
}
The loading circle is never get hidden back as in screenshot below
What is wrong with my code and how can I solve it?
Upvotes: 3
Views: 3926