我使用Fragement导航抽屉,因此不能用于onPostCreated调用syncState
public class NavigationDrawerFragment extends Fragment{
....
Run Code Online (Sandbox Code Playgroud)
调用syncState()上activityCreated
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Indicate that this fragment would like to influence the set of actions in the action bar.
setHasOptionsMenu(true);
mDrawerToggle.syncState();
}
Run Code Online (Sandbox Code Playgroud)
使用ic_drawerfor图标
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with …Run Code Online (Sandbox Code Playgroud)