“Activity not found” in Android

后端 未结 7 1411
后悔当初
后悔当初 2021-01-24 23:04

I am using the navigation-drawer template in eclipse to do a simple Android application. I have some trouble with fragment. I declared a fragment called PresenceL

相关标签:
7条回答
  • 2021-01-24 23:42

    You can't load a fragment through Intent. You have to do it using fragment manager in this way:

    Fragment fragment = new PresenceLogFragment(MainActivity.this);
    FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction ft = fragmentManager.beginTransaction();                
                ft.replace(R.id.yourFragmentContainer, fragment).commit();
    
    0 讨论(0)
提交回复
热议问题