在我的应用程序中,我使用导航抽屉,它工作得很好。但是,如果要显示的片段包含很多 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();
所以我想我会在菜单关闭后替换该片段..有什么想法吗?
As the 文件说:
Avoid performing expensive operations such as layout during animation as it can cause stuttering;
try to perform expensive operations during the STATE_IDLE state.
您可以做的是为您的抽屉设置一个事件侦听器,并在 onDrawerClosed 回调中执行片段操作(例子在这里).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)