0

에서 열지 탐색을 수행, 응용 프로그램이 닫히고이 오류입니다 :작업 표시 줄 서랍 토글 내가 켜고 끌을 터치하면 내가 NavigationView 및 ActionBarDrawer 전환 에 문제가 하바 바로

Process: net.diginic.master, PID: 21770 
        java.lang.IllegalArgumentException: No drawer view found with 
    gravity LEFT 
         at 
    android.support.v4.widget.DrawerLayout.openDrawer(DrawerLayout.java:1651) 
         at 
    android.support.v4.widget.DrawerLayout.openDrawer(DrawerLayout.java:1637) 
         at 

    android.support.v7.app.ActionBarDrawerToggle.toggle(ActionBarDrawerToggle.java:293) 
         at 

    android.support.v7.app.ActionBarDrawerToggle$1.onClick(ActionBarDrawerToggle.java:202) 
         at android.view.View.performClick(View.java:5637) 
         at android.view.View$PerformClick.run(View.java:22429) 
         at android.os.Handler.handleCallback(Handler.java:751) 
         at android.os.Handler.dispatchMessage(Handler.java:95) 
         at android.os.Looper.loop(Looper.java:154) 
         at android.app.ActivityThread.main(ActivityThread.java:6119) 
         at java.lang.reflect.Method.invoke(Native Method) 
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

네비게이션 중력이 맞다 | 끝 중력에 문제가 없다는 왼쪽하지만 난 개방 RTL 햄버거 메뉴 아이콘을 탐색하고 열기를 원하는

--MainActivity.java

public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener { 

    DrawerLayout drawerLayout; 
    NavigationView navigationView; 
    ActionBarDrawerToggle toggle; 
    Toolbar toolbar; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main_activity); 

     sliderLayout = (SliderLayout) findViewById(R.id.slider); 
     toolbar = (Toolbar) findViewById(R.id.toolbar); 
     drawerLayout = (DrawerLayout) findViewById(R.id.layout_drawer); 
     navigationView = (NavigationView) findViewById(R.id.navigation_view); 

     setSupportActionBar(toolbar); 
     setSupportActionBar(toolbar); 
     getSupportActionBar().setDisplayShowTitleEnabled(false); 

     toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close); 
     drawerLayout.setDrawerListener(toggle); 
     toggle.syncState(); 
     navigationView.setNavigationItemSelectedListener(this); 



    } 

    @Override 
    public void onBackPressed() { 
     if (drawerLayout.isDrawerOpen(GravityCompat.END)) { 
      drawerLayout.closeDrawer(GravityCompat.END); 
     } else { 
      super.onBackPressed(); 
     } 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     getMenuInflater().inflate(R.menu.menu, menu); 
     return super.onCreateOptionsMenu(menu); 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     switch (item.getItemId()) { 
      case android.R.id.home: 
       if (drawerLayout.isDrawerOpen(Gravity.RIGHT)) { 
        drawerLayout.closeDrawer(Gravity.RIGHT); 
       } else { 
        drawerLayout.openDrawer(Gravity.RIGHT); 
       } 
       return true; 
     } 
     return super.onOptionsItemSelected(item); 
    } 

    @Override 
    public boolean onNavigationItemSelected(MenuItem item) { 
     int id = item.getItemId(); 
     switch (id) { 
      case R.id.drawer_home: 
       break; 
      case R.id.drawer_sort_list: 
       break; 
      case R.id.drawer_shopping_cart: 
       break; 
      case R.id.drawer_most_buy: 
       break; 
      case R.id.drawer_most_see: 
       break; 
      case R.id.drawer_newest: 
       break; 
      case R.id.drawer_settings: 
       break; 
      case R.id.drawer_faq: 
       break; 
      case R.id.drawer_about: 
       break; 
     } 
     drawerLayout.closeDrawer(Gravity.RIGHT); 
     return true; 
    } 
} 
0 오른쪽에서

--main_activity.xml

<?xml version="1.0" encoding="utf-8"?> 


<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/layout_drawer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="end"> 

    <include layout="@layout/main_content" /> 

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="end" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.NavigationView 
      android:id="@+id/navigation_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="end" 
      android:layoutDirection="rtl" 
      app:headerLayout="@layout/header" 
      app:menu="@menu/main_drawer"> 

     </android.support.design.widget.NavigationView> 
    </android.support.design.widget.CoordinatorLayout> 
</android.support.v4.widget.DrawerLayout> 

답변

0

시도는에서 onCreate()의 하단이 추가

toolbar.setNavigationOnClickListener(new View.OnClickListener() { 

@Override 
public void onClick(View v) { 
    if (Drawer.isDrawerOpen(Gravity.END)) { 
     Drawer.closeDrawer(Gravity.END); 
    } else { 
     Drawer.openDrawer(Gravity.END); 
    } 
} 
});