I'm currently implementing swipeRefreshLayout
the problem was, it's still not showing up. I tried to implement some of the answer in this link ,and this link ,and this link .
my gradle module: compile 'com.android.support:appcompat-v7:23.1.1'
Here's my sample xml:recycler_view
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/recycler_relative_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/feeds_swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="@dimen/activity_vertical_margin"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.SwipeRefreshLayout>
Java Code:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//INFLATE
mRelativeLayoutRoot = (RelativeLayout) inflater.inflate(R.layout.recycler_view,container,false)
.findViewById(R.id.recycler_relative_root);
//MAP SWIPE REFRESH
mSwipeRefreshLayout = (SwipeRefreshLayout) mRelativeLayoutRoot.findViewById(R.id.feeds_swipe_refresh);
//MAP RECYCLER VIEW
recyclerView = (RecyclerView) mRelativeLayoutRoot.findViewById(R.id.my_recycler_view);
//RECYCLER VIEW LAYOUT
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setHasFixedSize(true);
//ORG ADAPTER
orgListAdapter = new OrgListAdapter(organizationDataList);
recyclerView.setAdapter(orgListAdapter);
//GET DATA REQUEST
parseJSONData();
return recyclerView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
parseJSONData();
}
});
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});
mSwipeRefreshLayout.setColorSchemeColors(R.color.appIntroColorFifth,
R.color.appIntroColorFourth,
R.color.appIntroColorOne,
R.color.appIntroColorTwo);
}
Whenever I swipe down, nothing happens, swipe refresh doesn't show up either.
I test this on an actual device running API 19 (Kitkat)
and API 23 (Marshmallow)
in emulator.