There is an activity in which 2 fragments constantly alternate, after the fragment replacement code, the code in which the view elements of this fragment are filled occurs, but nullPointException is thrown because the onCreateView in the fragment has not yet been called. What is the problem, how can I synchronize these actions?
Everything happens here, the fragment still does not have time to appear on the screen, as the call to the setFocusPlayer method occurs, which it tries to fill the view in the fragment
private void setTalkScreen() { replaceFragment(playersTalkFragment); if (world.isPlayerInGame(0)) { setFocusPlayer(0); } else { setFocusPlayer(world.nextPlayer(World.NONE)); } } private void replaceFragment(Fragment newFragment) { FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); transaction.replace(R.id.fragment_container, newFragment); transaction.commit(); Log.d(LOGIC, "GameActivity -> replaceFragment"); }
fragmentManager? - Rostislav Dugin