导航抽屉速度慢,视图复杂

Fab*_*eci 7 performance android view android-fragments navigation-drawer

在我的应用程序中,我使用导航抽屉,它工作得非常好.但是如果要显示的片段包含很多TextView,ImageView和Layout,当我单击该项时,视图就会出现故障.我会改善这种滞后.我的Galaxy Nexus和Nexus 4的效果是一样的,所以我认为问题在于我同时有2个命令.

  //On item click - First comand (Close Drawer) 
  mDrawerList.setItemChecked(position, true);
  setTitle(mStringTitles[position]);
  mDrawerLayout.closeDrawer(mDrawerView);

    // Second comand (Replace Fragment)        
    getFragmentManager()
   .beginTransaction()
   .replace(R.id.firts_view, new FragmentNew())
   .commit();
Run Code Online (Sandbox Code Playgroud)

所以我想我会在菜单关闭后更换片段..任何想法?

mbm*_*bmc 7

正如文件所说:

Avoid performing expensive operations such as layout during animation as it can cause stuttering;
try to perform expensive operations during the STATE_IDLE state.
Run Code Online (Sandbox Code Playgroud)

你可以做的是,你的抽屉有一个事件监听器,并在onDrawerClosed回调中进行片段操作(这里的例子).