Swiperefreshlayout Setrefreshing() Not Showing Indicator Initially

SwipeRefreshLayout setRefreshing() not showing indicator initially

Faced with same issue. My solution -

mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});

SwipeRefreshLayout setRefreshing not showing progress bar in Fragment

If you want to be able to pull refresh the empty view you'll have to put the FrameLayout (that includes the ListView and the EmptyView) inside the SwipeRefreshLayout. Also, set android:clickable="true" in the FrameLayout

try this code:

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pending_bookings"
android:layout_gravity="center_horizontal"
android:divider="@null"
android:visibility="gone"/>
<TextView
android:id="@+id/no_bookings_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/no_vehicles"
android:textSize="25dp"
android:textAlignment="center"/>
</FrameLayout>

credit to antoinem

EDIT

In case you have problem in scrolling up your list. That everytime you scroll up in that view SwipeRefreshLayout fires and updates, making your app unable to scroll up in a list. Add this code in your Activity or fragment:

listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {

}

@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
int topRowVerticalPosition = (listView == null ||
listView.getChildCount() == 0) ? 0 : listView.getChildAt(0).getTop();
swipeRefreshLayout.setEnabled(firstVisibleItem == 0 && topRowVerticalPosition >= 0);
}
});

credit to this post by Nacho Lopez

setRefreshing(true) does not show indicator

It actually does show the indicator...behind the ActionBar!

The way I fixed it was below:

    Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int height = size.y;
getSwipeRefreshLayout().setProgressViewOffset(false, -200, height / 9);

EDIT

The above is no longer the correct answer. The correct answer is below:

getSwipeRefreshLayout().post(new Runnable() {
@Override public void run() {
getSwipeRefreshLayout().setRefreshing(true);
}
});

SwipeRefreshLayout doesn't show any indicator of refreshing

I discovered the issue is that my app uses translucent UI on Android 4.4, padding is set to the top of the list and bottom of the list so that it goes under the action bar and above the navigation bar. Since the ListView becomes a child of the SwipeRefreshLayout, the padding should be set to the SwipeRefreshLayout instead of the ListView like I had been before I switched to using SwipeRefreshLayout.

My imageview not showing up after swiperefreshlayout

Try this

<android.support.v4.widget.SwipeRefreshLayout 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:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/second_category_rcV"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher_background" />

<ProgressBar
android:id="@+id/second_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:indeterminateBehavior="repeat"
android:visibility="visible" />

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

RESULT

enter image description here



Related Topics



Leave a reply



Submit