小编vik*_*iki的帖子

汉堡图标不显示在导航抽屉碎片中

我使用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)

android android-fragments navigation-drawer

7
推荐指数
2
解决办法
1万
查看次数