Issues In Implementing Gridview Within A Fragment
I am working on a small application which contains Activity with NavigationDrawer, and i have placed a fragment on that activity using FragmentManager and FragmentTrancation. Probl
Solution 1:
You're not respecting the Activity
lifecycle. When you do this
FragmentManagerFM= getFragmentManager();
FragmentTransactionTrans= FM.beginTransaction();
before the method onCreate
being called, you don't have the Activity
properly created.
Move that code to the onCreate
method:
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);
setContentView(R.layout.navigation_drawer);
AddAppsAapps=newAddApps();
drawerlayout = (DrawerLayout) findViewById(R.id.drawer_layout);
LVdrawer = (ListView) findViewById(R.id.left_drawer);
LVdrawer.setAdapter(newCustomAdapter(this, 1));
FragmentManagerFM= getFragmentManager();
FragmentTransactionTrans= FM.beginTransaction();
Trans.add(R.id.content_frame, Aapps, "AddAppsF");
Trans.addToBackStack("AddApps");
Trans.commit();
}
Post a Comment for "Issues In Implementing Gridview Within A Fragment"