IT/Android
Kotlin] 안드로이드 당겨서 새로고침 // SwipeRefreshLayout
깻잎쌈
2020. 3. 20. 21:50
반응형
build.gradle 추가해주고
dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
}
activity_main.xml
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/pullToRefresh"
android:layout_width="match_parent"
android:layout_height="0dp"
.
.
>
<ListView
android:id="@+id/listView"
.
.
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
MainActivity.kt
// 당겨서 새로고침
pullToRefresh.setOnRefreshListener {
//새로고침 내용
items.clear()
.
.
// 새로고침 중지
// 없으면 새로고침 애니메이션 끝나지 않음
pullToRefresh.isRefreshing = false
}
https://javapapers.com/android/android-swipe-down-to-refresh-a-listview/
Android Swipe Down to Refresh a ListView - Javapapers
This Android tutorial is about refreshing a ListView by swiping down. It will enable the user to refresh the Android ListView in an Android
javapapers.com
참 쉽쥬
반응형