“Android RecyclerView Pull para atualizar” Respostas de código

Android RecyclerView Pull para atualizar

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);
        }
    }
    }
Frantic Ferret

Android RecyclerView Pull para atualizar

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/layout_titlebar">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/layout_titlebar"
        android:layout_margin="5dp"
        />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
Frantic Ferret

Respostas semelhantes a “Android RecyclerView Pull para atualizar”

Perguntas semelhantes a “Android RecyclerView Pull para atualizar”

Mais respostas relacionadas para “Android RecyclerView Pull para atualizar” em Java

Procure respostas de código populares por idioma

Procurar outros idiomas de código