반응형
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/
참 쉽쥬
반응형
'IT > Android' 카테고리의 다른 글
Kotlin] toast 메세지 // 배경, 글자 크기, 글자색 설정하기 (0) | 2020.03.31 |
---|---|
Kotlin] 안드로이드 알람 설정 & 해제 (0) | 2020.03.29 |
Kotlin] 안드로이드 리스트뷰 삭제 (다중선택) (0) | 2020.03.18 |
Kotlin] 안드로이드 리스트뷰 삭제 (단일선택) (0) | 2020.03.18 |
Kotlin] 안드로이드 토스트 메세지 위치 // 중앙으로 (0) | 2020.03.18 |
댓글