SmoothBottomBar icon indicating copy to clipboard operation
SmoothBottomBar copied to clipboard

Can I use it in java code ?

Open exzant opened this issue 4 years ago • 4 comments

How ?

exzant avatar Dec 24 '19 23:12 exzant

bottomBar.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelect(int i) { Log.d("",i + ""); } });

AbedQa avatar Feb 07 '20 13:02 AbedQa

smoothBottomBar.setOnItemSelectedListener(i -> {
    // i = the currently selected index
});

smoothBottomBar.setOnItemReselectedListener(i -> {
    // i = the currently reselected index
});

The above code can be used for setting the item selected and item reselected listeners. But to have this kind of simple expression you need to enable Java1.8 compile option.

go to your app.gradle file and add the following snippet inside the android object

android {
   ...
   
   compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

brookmg avatar Apr 09 '20 09:04 brookmg

i need in java

sureshios avatar May 13 '20 05:05 sureshios

private NavController navController;
private SmoothBottomBar bottomNavigationView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bottomNavigationView = findViewById(R.id.bottomBar);
    navController = Navigation.findNavController(this, R.id.nav_host_fragment);
    NavigationUI.setupActionBarWithNavController(this, navController);

    setupSmoothBottomBar();

}

private void setupSmoothBottomBar() {
    PopupMenu popupMenu = new PopupMenu(this, null);
    popupMenu.inflate(R.menu.bottom_nav);
    Menu menu  = popupMenu.getMenu();
    bottomNavigationView.setupWithNavController(menu, navController);
}

@Override
public boolean onSupportNavigateUp() {
    return navController.navigateUp() || super.onSupportNavigateUp();
}

1902shubh avatar May 14 '21 09:05 1902shubh