I am working on a small application which contains Activity with NavigationDrawer
, and i have placed a fragment on that activity using FragmentManager
You're not respecting the Activity
lifecycle. When you do this
FragmentManager FM = getFragmentManager();
FragmentTransaction Trans = FM.beginTransaction();
before the method onCreate
being called, you don't have the Activity
properly created.
Move that code to the onCreate
method:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.navigation_drawer);
AddApps Aapps = new AddApps();
drawerlayout = (DrawerLayout) findViewById(R.id.drawer_layout);
LVdrawer = (ListView) findViewById(R.id.left_drawer);
LVdrawer.setAdapter(new CustomAdapter(this, 1));
FragmentManager FM = getFragmentManager();
FragmentTransaction Trans = FM.beginTransaction();
Trans.add(R.id.content_frame, Aapps, "AddAppsF");
Trans.addToBackStack("AddApps");
Trans.commit();
}