我在使用导航抽屉时遇到了问题,它太慢了。我正在寻找的解决方案是先关闭抽屉然后再显示活动页面,但是它没有起作用,显然我漏掉了什么。
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int posicao, long id) {
setLastPosition(posicao);
setFragmentList(lastPosition);
layoutDrawer.closeDrawer(linearDrawer);
}
}
private OnClickListener userOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
layoutDrawer.closeDrawer(linearDrawer);
}
};
private void setFragmentList(int posicao) {
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = new FragmentViagens();
switch (posicao) {
case 0:
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
break;
case 1:
fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentPedidos()).commit();
break;
case 2:
fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentClientes()).commit();
break;
}
navigationAdapter.setChecked(posicao, true);
setTitleFragments(lastPosition);
navigationAdapter.resetarCheck();
layoutDrawer.closeDrawer(linearDrawer);
}