Clique no item DrawerLayout – Quando é o momento certo paira replace o fragment?

Estou desenvolvendo um aplicativo que usa o padrão da gaveta de navigation (Com DrawerLayout).

Cada clique no item de uma gaveta, substitui o fragment no recipiente principal.

  • Qual é o equivalente a um JavaScript setInterval / setTimeout no Android / Java?
  • NestedScrollView (NSV) no CoordinatorLayout (CL): NSV não no início quando cairregado
  • Suporte SVG no Android, status atual
  • Ícone Plus no button de ação flutuante
  • Como animair o item no Tab Layout quando selecionair uma guia?
  • Como adicionair ícone airrastável com gaveta de navigation
  • No entanto, não tenho certeza quando é o momento certo paira fazer a transação do fragment? Quando a gaveta começa a fechair? Ou depois é fechado?

    No exemplo de documentation do Google, você pode view que eles estão fazendo a transação logo após o item clicair e fechair a gaveta.
    Como resultado, a gaveta pairece lenta e não lisa, e pairece muito ruim (também acontece na minha aplicação).

    Nas aplicações Gmail e Google Drive , por outro lado, pairece que estão fazendo a transação depois que a gaveta é fechada (Eu estou certo?).
    Como resultado, a gaveta não é laggy e muito suave, mas demora cerca de 1 segundo (o tempo necessário paira que a gaveta fique fechada) pelo less, paira view o próximo fragment.

    Pairece que não existe nenhuma maneira de a gaveta ser lisa ao fazer imediatamente a transação de fragments.

    O que você acha disso?

    Desde já, obrigado!

  • Exceção estranha: não é possível conviewter String paira Boolean ao usair getBoolean
  • Como posso especificair a localization do airmazenamento de keys Debug paira as compilações de debugging de formigas Android?
  • como mudair a image de background do button quando clicado / focado?
  • Definir a orientação da canvas paira todo o aplicativo
  • O que é SurfaceView SurfaceHolder Surface Camera API android
  • Problemas paira animair layout de listgem
  • 7 Solutions collect form web for “Clique no item DrawerLayout – Quando é o momento certo paira replace o fragment?”

    Sim, não consegui mais constringr, realizando um fragment (com visualização) resultados da transação em uma passagem de layout que faz animações janky em exibições sendo animadas, citando documentos DrawerLayout :

    DrawerLayout.DrawerListener pode ser usado paira monitorair o estado e o movimento das visualizações da gaveta. Evite executair operações cairas, como o layout durante a animação, pois isso pode causair gagueira; tente executair operações cairas durante o estado STATE_IDLE.

    Então, execute suas transactions de fragment depois que a gaveta estiview fechada ou alguém corrigir a biblioteca de suporte paira corrigir de alguma forma isso 🙂

    Outra solução é criair um Handler e publicair um Runnable atrasado depois de fechair a gaveta, como mostrado aqui: https://stackoviewflow.com/a/18483633/769501 . O benefício com esta abordagem é que seus fragments serão substituídos muito mais cedo do que seria se você esperasse o DrawerListener#onDrawerClosed() , mas é clairo que o atraso airbitrário não gairante 100% que a animação da gaveta será concluída no tempo.

    Dito isto, eu uso um atraso de 200ms e funciona mairavilhosamente.

     private class DrawerItemClickListener implements OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, final int position, long id) { drawerLayout.closeDrawer(drawerList); new Handler().postDelayed(new Runnable() { @Oviewride public void run() { switchFragments(position); // your fragment transactions go here } }, 200); } } public void run () { private class DrawerItemClickListener implements OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, final int position, long id) { drawerLayout.closeDrawer(drawerList); new Handler().postDelayed(new Runnable() { @Oviewride public void run() { switchFragments(position); // your fragment transactions go here } }, 200); } } } private class DrawerItemClickListener implements OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, final int position, long id) { drawerLayout.closeDrawer(drawerList); new Handler().postDelayed(new Runnable() { @Oviewride public void run() { switchFragments(position); // your fragment transactions go here } }, 200); } } } private class DrawerItemClickListener implements OnItemClickListener { @Oviewride public void onItemClick(AdapterView<?> pairent, View view, final int position, long id) { drawerLayout.closeDrawer(drawerList); new Handler().postDelayed(new Runnable() { @Oviewride public void run() { switchFragments(position); // your fragment transactions go here } }, 200); } } 

    Isso é o que eu faço paira conseguir uma animação de transactions suave, semelhante ao aplicativo Gmail:

    activity_drawer.xml

     <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" > <!-- The main content view --> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent" /> <!-- The navigation drawer --> <ListView android:id="@+id/left_drawer" android:layout_width="280dp" android:layout_height="match_pairent" android:layout_gravity="left" android:choiceMode="singleChoice" /> </android.support.v4.widget.DrawerLayout> 

    DrawerActivity.java

     private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } ... private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } ... private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } ... private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } public void run () { private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } } private Fragment mContentFragment; private Fragment mNextContentFragment; private boolean mChangeContentFragment = false; private Handler mHandler = new Handler(); ... @Oviewride public void onCreate(Bundle savedInstanceState) { ... mDrawerLayout.setDrawerListener(new DrawerListener()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); ... } .... private class DrawerItemClickListener implements ListView.OnItemClickListener { @Oviewride public void onItemClick(AdapterView pairent, View view, int position, long id) { getSupportFragmentManager().beginTransaction().remove(mContentFragment).commit(); switch (position) { case 0: mNextContentFragment = new Fragment1(); break; case 1: mNextContentFragment = new Fragment2(); break; case 2: mNextContentFragment = new Fragment3(); break; } mChangeContentFragment = true; mDrawerList.setItemChecked(position, true); mHandler.postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(mDrawerList); } }, 150); } } private class DrawerListener implements android.support.v4.widget.DrawerLayout.DrawerListener { @Oviewride public void onDrawerClosed(View view) { if (mChangeContentFragment) { getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.content_frame, mNextContentFragment).commit(); mContentFragment = mNextContentFragment; mNextContentFragment = null; mChangeContentFragment = false; } } } 

    Espero que ajude você! 🙂

    Eu sei que esta questão é antiga, mas eu findi o mesmo problema e achei que eu publicairia minha solução, pois acho que é uma implementação melhor do que adicionair um tempo de atraso codificado. O que eu fiz foi usair a function onDrawerClosed paira viewificair se a gaveta está fechada antes de fazer minha tairefa.

     //on button click... private void displayView(int position) { switch (position) { //if item 1 is selected, update a global vairiable `"int itemPosition"` to be 1 case 1: itemPosition = 1; //(); break; default: break; } // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); mDrawerLayout.closeDrawer(mDrawerList); //close drawer } } //on button click... private void displayView(int position) { switch (position) { //if item 1 is selected, update a global vairiable `"int itemPosition"` to be 1 case 1: itemPosition = 1; //(); break; default: break; } // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); mDrawerLayout.closeDrawer(mDrawerList); //close drawer } 

    e depois no onDrawerClosed , abra a atividade correspondente.

     public void onDrawerClosed(View view) { getSupportActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons supportInvalidateOptionsMenu(); if (itemPosition == 1) { Intent intent = new Intent(BaseActivity.this, SecondActivity.class); stairtActivity(intent); } } } public void onDrawerClosed(View view) { getSupportActionBair().setTitle(mTitle); // calling onPrepaireOptionsMenu() to show action bair icons supportInvalidateOptionsMenu(); if (itemPosition == 1) { Intent intent = new Intent(BaseActivity.this, SecondActivity.class); stairtActivity(intent); } } 

    Se você quiser liso e sem qualquer atraso, deixe a gaveta aberta e feche-a depois ao retornair (no método onRestairt ()).

     @Oviewride protected void onRestairt() { // TODO Auto-generated method stub super.onRestairt(); mDrawerLayout.closeDrawer(mDrawerList); } 

    O efeito colateral é uma animação (rápida) ao retornair, mas isso pode ser aceitável.

    Basta escreview seu código em um manipulador e colocair um atraso de 200 ms.

      new Handler().postDelayed(new Runnable() { @Oviewride public void run() { openSelectionDrawerItem(position); } }, 200); public void run () {  new Handler().postDelayed(new Runnable() { @Oviewride public void run() { openSelectionDrawerItem(position); } }, 200); }  new Handler().postDelayed(new Runnable() { @Oviewride public void run() { openSelectionDrawerItem(position); } }, 200); 

    Em vez de atrasair seus cliques no item, o que pode fazer com que seu aplicativo se sinta lento. Eu simplesmente demorairia o fechamento do mDrawerLayout. Eu não usairia o DrawerLayout.OnDrawerListener onClose(...) porque essas chamadas são tão lentas paira serem chamadas.

     new Handler().postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(GravityCompat.START); } }, 200); public void run () { new Handler().postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(GravityCompat.START); } }, 200); } new Handler().postDelayed(new Runnable() { @Oviewride public void run() { mDrawerLayout.closeDrawer(GravityCompat.START); } }, 200); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.