The layout is not updated to replace the fragment, but the class starts.



  • Good afternoon, in the past project, I've replaced the code slic calmly:

    android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = Fragment.instantiate(getApplication(), SecondFragment.class.getName());
    android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.fragmentview, fragment);
    ft.commit();
    

    But the new project doesn't work, it doesn't make any mistakes.

    I'd like to point out that it's class. SecondFragment starting, but Loayout in whichR.id.fragmentview() Not updated, there remains an old fragment.

    I've been watching Tutorials for five hours, trying different codes, but nothing helps.

    What's the problem?

    Maybe there's another way to replace and reload the fragment class?



  • It's likely that your (most google) problem is that the original fragment you put right in the marking, not in the code. I mean, it's a bug. Try the original, first fragment, remove it from the marking and add it by method. add from the code.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2