2016-12-13 59 views
-1

我必须使用https://github.com/lewisjdeane/L-Navigation-Drawer剂量不显示菜单抽屉项

,但在我的手机菜单剂量不会在我的手机显示的项目 当我打开菜单剂量不显示项目和空(白)

代码在MainActivty.java

protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 
     getSupportActionBar().setDisplayHomeAsUpEnabled(true); 


     vorod=(Button) findViewById(R.id.main_vorod); 

     NavigationListView navigationListView = (NavigationListView) findViewById(R.id.navigation_list_view); 

     int[] images = new int[]{ 
     R.drawable.setting, 
     R.drawable.like 
     }; 


     new NavigationItem("setting",images[1],true); 
     new NavigationItem("setting2",images[1],false); 
     new NavigationItem("setting3",images[1],false); 
     new NavigationItem("setting4",images[1],false); 
     navigationListView.setSelectedItem(0); 

和actvity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.sayeben.karagah.MainActivity" 
    android:background="@mipmap/bg"> 

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:local="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     local:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 


    <android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <!-- The main content view --> 
     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <!-- Put your layout design in here --> 

     </FrameLayout> 
     <!-- The navigation list view --> 
     <uk.me.lewisdeane.lnavigationdrawer.NavigationListView 
      android:id="@+id/navigation_list_view" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="end" 
      android:choiceMode="singleChoice" 
      android:divider="@android:color/transparent" 
      android:dividerHeight="0dp" 
      android:background="#FFFFFF"/> 
    </android.support.v4.widget.DrawerLayout> 
</RelativeLayout> 
+0

这个图书馆,我认为没有那么好每一个项目似乎已被弃用。尝试使用https://github.com/mikepenz/MaterialDrawer – Beloo

回答

0

请使用

navigationListView.addNavigationItem(String title, int imgRes, boolean selected); 

项添加到NavigationView

+0

谢谢,如何设置从右到左的文字? – mohammadalian

+0

如果它有帮助请接受它 –

+0

这可能有助于android:textDirection =“rtl” –

0

我想你应该添加要导航菜单上显示,以navigationListView

navigationListView.add(new NavigationItem("setting",images[1],true));