I had use BottomNavigationView in my activity_main.xml, at first I only put 1 item in my menu, but then later on I added more item in my menu, but it only show the item I added at beginning even if I remove everything in my menu, it still only show the item I put in my menu at beginning. How can I fix this?
I had tried rebuild the whole activity_main.xml and menu.xml, but it still not fixed. Below is my activity_main.xml and menu.xml
menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/home"
android:title="@string/Home"
android:icon="@drawable/home" />
<item android:id="@+id/profile"
android:title="@string/Profile"
android:icon="@drawable/profile" />
</menu>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/yellow"
app:itemIconTint="@color/black"
app:itemTextColor="@color/black"
app:labelVisibilityMode="auto"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
Dependencies:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:support-core-utils:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:29.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
At beginning I only add item: Home, at later time I add my second item: Profile, but the navigation view show only Home which I added when the time I build it.