I am using bottom navigation bar, so I used three menu item in bottom navigation bar, my question is that I want to add some click eventon that button so when a user click on home button, it will come to the main activity from any activity and when user click on search bar, it will get a floating search bar in the bottom.
Put this code in onCreate() of your activity
BottomNavigationView bottomNavigationView = (BottomNavigationView)findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.home:
//Add your action onClick
break;
case R.id.search:
break;
case R.id.favorite:
break;
}
return false;
}
});
Here is the tutorial teach you add bottom navigation bar step by step.
see : blog_iamsuleiman
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.