I believe the question in this context is being viewed in different contexts basing on answers here.
According to assessment, whats required is ability to focus on specific BottomNavigationView
item (definitely in new class holding different fragments).
Now, you could have BottomNavigationView OR Buttons or Anything clickable to launch new activity on intent : -
i.e
Intent intent = new Intent(getActivity(), New_Activity.class);
intent.putExtra("EXTRA_PAGE, 1);
startActivityForResult(intent, 30);
Then
-in our New_Activity, we receive the intent-
Intent intent = getIntent();
int page = intent.getExtras().getInt("EXTRA_PAGE);
We then loop over the page variable to find the number/Index for which the current BottomNavigationView is reflecting , THEN we set our focus menu item (assuming your BottomNavigationView has Menu Item for its display)
if(page == 1) {
currentselect = new Pending();
bottomNavigationView.getMenu().getItem(0).setChecked(true);
}
This answers the question above. The rest of Fragment switch is handled well by number of posts above by invoking :
bottomNavigationView.setOnNavigationItemSelectedListener(navListener);
Then something like :
private BottomNavigationView.OnNavigationItemSelectedListener navListener =
new BottomNavigationView.OnNavigationItemSelectedListener(){
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment selectedFrag = null;
switch (item.getItemId()) {
case R.id.pending:
selectedFrag = new Pending();
break;
case R.id.onTransmit:
selectedFrag = new inTransmit();
break;
case R.id.complete:
selectedFrag = new Complete();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.select_field, selectedFrag).commit();
return true;
}
};
NOTE:
Using BottomNavigationView and ContentFrameLayout is soo economical and will slash down your code to over 50 % unlike using likes of ViewPager and Tablayout