Kotlin
[안드로이드 스튜디오] tablayout의 tabitem 사용시 java.lang.NullPointerException: Missing required view with ID
무하지
2021. 9. 14. 21:29
반응형
java.lang.NullPointerException: Missing required view with ID
tablayout의 tabitem ID를 지정하는 경우 위와 같은 오류가 뜬다. 마테리얼 라이브러리를 사용하는 경우 발생하는 버그로 tabitem의 ID를 삭제해주면 해결된다.
참조: https://github.com/material-components/material-components-android/issues/1162
[Tab Items] Tab Items does not work with View Binding, throws NPE · Issue #1162 · material-components/material-components-andr
Description: Filing this in response to ja...@google.com comment on https://issuetracker.google.com/issues/145687658 a....@tandu.it I have a view which contains some TabItem with an ID. When I try ...
github.com
ID를 사용해서 tablayout에 접근하지 못하므로 tablayout의 api를 사용해야한다.
val tablayout = binding.tablayout
tablayout.getTabAt(0)!!.text = "blabla"
반응형