BottomBar
BottomBar copied to clipboard
Some issues with data binding
I had a hard time trying to make the bottom bar to work with data binding in my activity.
The bottom bar just wouldn't show.
I fixed the problem by moving the binding code before the bottom bar initialization in the onCreate method.
Here is an example:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// This goes...
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.setActivity(this);
// ...before this
mBottomBar = BottomBar.attach(this, savedInstanceState);
mBottomBar.setItems(R.menu.bottombar_menu);
mBottomBar.setOnMenuTabClickListener(new OnMenuTabClickListener() {
@Override
public void onMenuTabSelected(@IdRes int menuItemId) {
if (menuItemId == R.id.bottomBarItemOne) {
// The user selected item number one.
}
}
@Override
public void onMenuTabReSelected(@IdRes int menuItemId) {
if (menuItemId == R.id.bottomBarItemOne) {
// The user reselected item number one, scroll your content to top.
}
}
});
}
Hopefully, this will help somebody.