Is it possible to use this library into JAVA project?
kghanva opened this issue · 6 comments
kghanva commented
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?
susonthapa commented
I think so. I haven't tried it but it should work just fine.
PremVarma commented
Yes you can use this using java
tabish075 commented
Can you Please share java documentation as well?
khyatip19 commented
Can you show how to add menu items in Java
susonthapa commented
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);
}
khyatip19 commented
Thank you so much. It really means a lot .
…On Thu, Feb 25, 2021, 7:16 AM susonthapa ***@***.***> wrote:
Closed #3
<#3>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM2K7CXYKDMG7HXHFCWQVHDTAWTV5ANCNFSM4UJ7LTNQ>
.