Open otcroz opened 2 years ago
BottomNavigationView에서 android:layout_width="0dp"
로 설정해놓고 왜 안되지~ 이러고 있는 유수연의 멍청함
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:menu="@menu/menu_bottom_navbar" />
드디어 나브바 아이콘이 보인다.. 1시간 만에
지금까지 앱 실행할 때 홈 프래그먼트가 보이지 않았던 이유
bn.selectedItemId = R.id.navigation_home
이거 설정 안해서..
bn.setOnItemSelectedListener{
replaceFragment(
when (it.itemId){
R.id.navigation_home -> HomeFragment()
R.id.navigation_map ->MapFragment()
R.id.navigation_list -> ListFragment()
else -> CourseFragment()
}
)
true
}
bn.setOnItemSelectedListener{
replaceFragment(
when (it.itemId){
R.id.navigation_home -> HomeFragment()
R.id.navigation_map ->MapFragment()
R.id.navigation_list -> ListFragment()
else -> CourseFragment()
}
)
true
}
**bn.selectedItemId = R.id.navigation_home**
setOnNavigationItemSelectedListener deprecated 해결하기
https://velog.io/@kimbsu00/Android-8
setOnItemSelectedListener 을 사용하면 된다.