susonthapa/curved-bottom-navigation

Is it possible to use this library into JAVA project?

Closed this issue · 6 comments

I want to use this awesome library for my JAVA project but unable to do so,
Can you please provide the sample code for it?

I think so. I haven't tried it but it should work just fine.

Yes you can use this using java

Can you Please share java documentation as well?

Can you show how to add menu items in Java

It's pretty easy to convert the code to java. Here is the code for the MainActivity in java. I have tested this in java and it's working as expected, closing the issue.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);

        NavController navController = navHostFragment.getNavController();
        AppBarConfiguration configuration = new AppBarConfiguration.Builder(
                R.id.nav_host_fragment,
                R.id.navigation_dashboard,
                R.id.navigation_notifications,
                R.id.navigation_profile,
                R.id.navigation_settings
        ).build();

        ActivityKt.setupActionBarWithNavController(this, navController, configuration);
        CbnMenuItem[] cbnMenuItems = {
                new CbnMenuItem(
                        R.drawable.ic_notification,
                        R.drawable.avd_notification,
                        R.id.navigation_notifications
                ),
                new CbnMenuItem(
                        R.drawable.ic_dashboard,
                        R.drawable.avd_dashboard,
                        R.id.navigation_dashboard
                ),
                new CbnMenuItem(
                        R.drawable.ic_home,
                        R.drawable.avd_home,
                        R.id.navigation_home
                ),
                new CbnMenuItem(
                        R.drawable.ic_profile,
                        R.drawable.avd_profile,
                        R.id.navigation_profile
                ),
                new CbnMenuItem(
                        R.drawable.ic_settings,
                        R.drawable.avd_settings,
                        R.id.navigation_settings
                )
        };
        binding.navView.setMenuItems(cbnMenuItems, 2);
        binding.navView.setupWithNavController(navController);
    }