Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

android recyclerview pull to refresh

public class BooksActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {

            SwipeRefreshLayout swipLayout;
            RecyclerView recyclerview;

        @Override
            protected void onCreate(@Nullable Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity);
                recyclerview = view.findViewById(R.id.recyclerview);
                swipLayout = view.findViewById(R.id.swipe_layout);
                swipLayout.setOnRefreshListener(this);
            }//end of onCreate

        @Override
            public void onRefresh() {
        //your refresh code here
           loadRecyclerViewData()
             }

        private void loadRecyclerViewData(){
        onSuccess(){
        //don't forget to stop refreshing
        swipLayout.setRefreshing(false);
        }

        onFaliure(){
        //don't forget to stop refreshing
        swipLayout.setRefreshing(false);
        }
    }
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #android #recyclerview #pull #refresh
ADD COMMENT
Topic
Name
5+8 =