Hanbit the Developer

[Kotlin] ListViewAdapter().notifyDataSetChanged() doesn't work. 본문

Mobile/Android

[Kotlin] ListViewAdapter().notifyDataSetChanged() doesn't work.

hanbikan 2021. 2. 28. 21:54

ListViewAdapter의 notifyDataSetChanged()는 기본적으로 UiThread에서 실행되어야 한다.

따라서, MainActivity에서 다음과 같은 코드를 써주면 작동이 된다.

runOnUiThread{
	adapter.notifyDataSetChanged()
}

 

추가로 만약 MainActivity가 아닌, 다른 Class에서 runOnUiThread를 사용하기 위해선 밑의 포스팅을 참고하자.

rccode.tistory.com/16