1

I have a bottom navigation bar as you can see below:

Main Picture

As you can see, I have a profile icon on the top, and when you press that, the 'Settings' item, at the last of the bottom navigation menu, should open up.

This is my java code:

public void openSettings(View v) {
    openFragment(com.Notely.Notes.fragments.NavigationSettings.newInstance("", ""));
}

This is my profile icon code:

<Button
    android:id="@+id/button"
    android:layout_width="45dp"
    android:layout_height="45dp"
    android:layout_marginLeft="290dp"
    android:layout_marginTop="20dp"
    android:background="@drawable/profile_btn"
    android:onClick="openSettings"
    app:layout_constraintStart_toStartOf="@+id/linearLayout"
    app:layout_constraintTop_toTopOf="@+id/linearLayout" />

In the above java code, when a person presses the profile icon, it should open the fragment Settings, but I want the item Settings also to be activated like the below picture:

Bottom Navigation

Thanks in advance.

1 Answers1

0

I think the best way to do that it is using BottomNavigationView there is a method call setSelectedId, have a look at this question:

Set selected item in Android BottomNavigationView