I'm using BottomBar in my main activity and I'm following the example code from github where he adds listeners to the tabs:
this.bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
switch (tabId) {
case R.id.tab_evaluate :
Toast.makeText(getApplicationContext(),"Evaluate",Toast.LENGTH_SHORT).show();
break;
case R.id.tab_info:
Toast.makeText(getApplicationContext(),"INfo",Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(getApplicationContext(),"Other",Toast.LENGTH_SHORT).show();
break;
}
}
});
It's working perfectly and I see all the toasts.
My problem: in my main activity I have two methods which I would like to call depending on the selected tab:
private void showQrCodeView(){
this.contentFrame.setVisibility(View.GONE);
this.qrCodeReaderView.setVisibility(View.VISIBLE);
}
private void hideQrCodeView(){
this.contentFrame.setVisibility(View.VISIBLE);
this.qrCodeReaderView.setVisibility(View.GONE);
}
To do so I trying this, which doesn't throw any errors but also doesn't work.
case R.id.tab_evaluate :
Toast.makeText(getApplicationContext(),"Evaluate",Toast.LENGTH_SHORT).show();
MainActivity.this.showQrCodeView();
break;
My question is how can I call my MainActivity methods from the OnTabSelectListener
?