App Crashing After I Rotate Device And Click The Menu
Solution 1:
You only call setupDrawer if your savedInstanceState is null. This mean it isn't called when you recreate the activity on rotation. However that's where you set the value of mDrawerLayout . So when onClick is called after rotation, mDrawerLayout is null. To fix this, you need to set the value of mDrawerLayout in both cases.
Actually I have no idea why you aren't calling setupDrawer when savedInstanceState is non null, it seems very wrong.
Solution 2:
Move
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);expListView = (ExpandableListView) findViewById(R.id.lvExp);
from setUpDrawer()
to onCreate()
before if block
.
Solution 3:
Ok i got it, had to modify somethings but it worked.
Took out the setUpDrawer()
from the if null
, like suggest from Gabe Sechan. and change it to
setUpDrawer();
if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, new Inicio()).commit();
}
I also deleted fragment = new Inicio();
and all the getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commit();
And updated all cases to case 0:fragment = new enunciados_definiciones(); break;
Thanks
Post a Comment for "App Crashing After I Rotate Device And Click The Menu"