“Activity not found” in Android

后端 未结 7 1409
后悔当初
后悔当初 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();
    

提交回复
热议问题