0
You guys good night, I really need a force, I am implementing a navigation Bottom to navigate through Fragments, but in one of the Fragments there will be a counter and when I navigate through the screens the counter restarts.
there is a way to save the status of the Fragment so that the counter remains?
Ever since I thank
mBottomNavigationView.setOnNavigationItemSelectedListener
(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected( MenuItem item) {
Fragment selectedFragment = null;
switch (item.getItemId()) {
case R.id.action_item1:
mTitle_Toolbar.setText(getString(R.string.toobar_call_activity));
//mToolbar.setLogo(R.mipmap.ic_reorder_white_24dp);
//selectedFragment = CalledFragment.newInstance();
fragmentManager(CalledFragment.newInstance(),getString(R.string.toobar_call_activity) );
break;
case R.id.action_item2:
mTitle_Toolbar.setText(getString(R.string.toobar_project_activity));
//mToolbar.setLogo(R.mipmap.ic_assignment_turned_in_white_24dp);
selectedFragment = ProjectsFragment.newInstance();
fragmentManager(Profilefragment.newInstance(),getString(R.string.toobar_project_activity) );
break;
case R.id.action_item3:
mTitle_Toolbar.setText(getString(R.string.toobar_profile_activity));
//mToolbar.setLogo(R.mipmap.ic_account_box_white_24dp);
//selectedFragment = Profilefragment.newInstance();
fragmentManager(Profilefragment.newInstance(), getString(R.string.toobar_profile_activity));
break;
}
//fragmentManager(selectedFragment);
return true;
}
});
mBottomNavigationView.setSelectedItemId(R.id.action_item1);
}
public void fragmentManager(Fragment mFragment, String tag){
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.frame_layout, mFragment);
transaction.addToBackStack(null);
transaction.commit();
}
An alternative is to keep the counter out of the fragment.
– Leonardo Lima
I thought about it, but I don’t know how I would update on the screen the chronometer
– Celso Andre
It would help if you explained the purpose of the counter and showed how it is initialized.
– Leonardo Lima