Complete the code to add a SwipeRefreshLayout in the XML layout.
<androidx.swiperefreshlayout.widget.[1] android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Your content here --> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
The root layout for pull-to-refresh is SwipeRefreshLayout.
Complete the Kotlin code to set the refresh listener on SwipeRefreshLayout.
swipeRefreshLayout.[1] {
// Refresh data here
swipeRefreshLayout.isRefreshing = false
}The method to listen for pull-to-refresh is setOnRefreshListener.
Fix the error in setting the refreshing state after data load.
swipeRefreshLayout.isRefreshing = [1]After refresh completes, set isRefreshing to false to hide the spinner.
Fill both blanks to create a SwipeRefreshLayout and set its color scheme.
val swipeRefreshLayout = findViewById<[1]>(R.id.swipeRefreshLayout) swipeRefreshLayout.setColorSchemeColors([2])
Use SwipeRefreshLayout for the view and set a color from android.R.color for the spinner.
Fill all three blanks to implement pull-to-refresh that updates a TextView.
swipeRefreshLayout.setOnRefreshListener {
textView.text = [1]
swipeRefreshLayout.isRefreshing = [2]
Toast.makeText(this, [3], Toast.LENGTH_SHORT).show()
}Set the TextView text to "Refreshed!", stop refreshing with false, and show a toast "Data updated".
