1

Hello guys am trying to make user login and if he is not an admin I want some bottom navigation bar hidden I want to hide item before activity showUp for user I am sending a certain value from activation of the user login and I want to verify before the screen appears to the user if the value is equal to the user answers hide the icon I tried to get to the icon id but I did not know the correct way to do that please help and thank you

@Override
protected void onStart() {
    super.onStart();
    BottomNavigationViewEx bottomNavigationViewEx = new BottomNavigationViewEx().findViewById(R.id.addproudactbtnbar).setVisibility(false);
}

my XML

    <com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/bottm_navigation_menu"
        android:background="@color/colorPrimary"
        app:menu="@menu/bottm_navigation_menu"
        >
    </com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx>







  public void setupbottmnavigationview(){

        BottomNavigationViewEx bottomnavigationviewex = findViewById(R.id.bottm_navigation_menu);
        BottomNvigationViewHelper.botomnavigationview(bottomnavigationviewex);
        BottomNvigationViewHelper.enebleactivty(Home.this , bottomnavigationviewex);
        Menu menu = bottomnavigationviewex.getMenu();
        MenuItem menuItem = menu.getItem(ATIVYTY_NUM);
        menuItem.setChecked(true);
        }

my navigation helper

public class BottomNvigationViewHelper {


    public  static void botomnavigationview (BottomNavigationViewEx bottomNavigationViewEx){
        bottomNavigationViewEx.enableAnimation(false);
        bottomNavigationViewEx.enableItemShiftingMode(false);
        bottomNavigationViewEx.enableShiftingMode(false);
        bottomNavigationViewEx.setTextVisibility(false);


    }


    public  static  void  enebleactivty(final Context context , BottomNavigationViewEx viewEx){
        viewEx.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {

                switch (item.getItemId()){
                    case R.id.homebtnbar:
                        Intent intent1 = new Intent(context, HomeScreenActivity.class);
                        context.startActivity(intent1);
                        break;
                    case R.id.profilebtnbar:
                        Intent intent2 = new Intent(context, ProfileScreenActivity.class);
                        context.startActivity(intent2);
                        break;
                    case R.id.searchusersbtnbar:
                        Intent intent3 = new Intent(context, SearchScreenActivity.class);
                        context.startActivity(intent3);
                        break;
                    case R.id.deleverybtnbar:
                        Intent intent4 = new Intent(context, DeleviryScreenActivity.class);
                        context.startActivity(intent4);
                        break;
                    case R.id.addproudactbtnbar:
                        Intent intent5 = new Intent(context, Addproudacts.class);
                        context.startActivity(intent5);
                        break;

                }

                return false;
            }
        });

    }
}
trusting
  • 11
  • 3

1 Answers1

1

You can inflate the menu programmatically based on the type of the user with

navigationView.getMenu().clear(); //clear old inflated items.
navigationView.inflateMenu(R.menu.new_navigation_drawer_items);

From this answer