0

I have a bottom navigation view in my Main Activity and I want to change it to show the icon and the text only for the selected item and to show only the icons of the other 2 items. I had an idea to change it in the code on click and set the other to items to empty string with this code:

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.navigation_home:
                //set text to home
                return true;
            case R.id.navigation_dashboard:
                //set to empty string
                return true;
            case R.id.navigation_notifications:
                //set to empty string
                return true;
        }
        return false;
    }

But I can't get to the textview of the item from the code... What can I do?

1 Answers1

1

Well, Here is what you want, Set other two text empty while selecting the current text :

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
        case R.id.navigation_home:
            //set text to home
            //set dashbord empty
            //set notification empty
            return true;
        case R.id.navigation_dashboard:
            //set text to dashbord
            //set home empty
            //set notification empty
            return true;
        case R.id.navigation_notifications:
            //set text to notification
            //set dashbord empty
            //set home empty
            return true;
    }
    return false;
}