2016-07-27 26 views
0

現在、ナビゲーション・ドロワー・アクティビティーを実装したい既存のプロジェクトがあります。現在、私は新しいナビゲーションドロワー活動を追加する場合、それは次のようなレイアウト生成します。代わりに私以上のレイアウトの、しかしナビゲーション・ドロワー・アクティビティー・テンプレートを既存のプロジェクトに追加する

Navigation Drawer Activity

は私ナビゲーション引き出しは正確にのように見えるデフォルトのテンプレートのようになりたいですこの(NAVヘッダからなる、など):

enter image description here

がどのように私はこれを達成するについて行くことができますか?私はAndroid開発の初心者です。

EDIT:

CREATING A NAVEGATIONDRAWER

答えて

0

を望んでいたものを達成するために私のアプリのテーマを変更するために必要な、アウトこれを確認新しい引き出しアクティビティ:

ファイル - >新規作成 - >アクティビティ - >ナビゲーションドロワー活動

1

作成し、私はちょうど私が答えになるか、この中にあなたを導く可能性があり、このリンクで

0
private void setupNavigationDrawer() { 
     //if you want to update the items at a later time it is recommended to keep it in a variable 
     PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(0).withName(R.string.drawer_item_home).withIcon(getResources().getDrawable(R.drawable.ic_home_white_24dp)); 
     PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(1).withName(R.string.drawer_item_login).withIcon(getResources().getDrawable(R.drawable.ic_account_circle_white_24dp)); 
     PrimaryDrawerItem item3 = new PrimaryDrawerItem().withIdentifier(2).withName(R.string.drawer_item_movies).withIcon(getResources().getDrawable(R.drawable.ic_movie_white_24dp)); 
     PrimaryDrawerItem item4 = new PrimaryDrawerItem().withIdentifier(3).withName(R.string.drawer_item_trailers).withIcon(getResources().getDrawable(R.drawable.ic_videocam_white_24dp)); 
     PrimaryDrawerItem item5 = new PrimaryDrawerItem().withIdentifier(4).withName(R.string.drawer_item_theatres).withIcon(getResources().getDrawable(R.drawable.ic_theaters_white_24dp)); 
     PrimaryDrawerItem item6 = new PrimaryDrawerItem().withIdentifier(5).withName(R.string.drawer_item_location).withIcon(getResources().getDrawable(R.drawable.ic_location_on_white_24dp)); 
     SecondaryDrawerItem item7 = (SecondaryDrawerItem) new SecondaryDrawerItem().withIdentifier(6).withName(R.string.drawer_item_about_us).withIcon(FontAwesome.Icon.faw_info_circle); 
     SecondaryDrawerItem item8 = (SecondaryDrawerItem) new SecondaryDrawerItem().withIdentifier(7).withName(R.string.drawer_item_contact_us).withIcon(FontAwesome.Icon.faw_whatsapp); 
     SecondaryDrawerItem item9 = (SecondaryDrawerItem) new SecondaryDrawerItem().withIdentifier(8).withName(R.string.drawer_item_feedback).withIcon(FontAwesome.Icon.faw_commenting); 
     SecondaryDrawerItem item10 = (SecondaryDrawerItem) new SecondaryDrawerItem().withIdentifier(9).withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_wrench); 

     // Create the AccountHeader 
     AccountHeader headerResult = new AccountHeaderBuilder() 
       .withActivity(this) 
       .withHeaderBackground(R.color.colorMaterialDark) 
       .addProfiles(
         new ProfileDrawerItem().withName(getResources().getString(R.string.app_name)).withEmail(getResources().getString(R.string.email_id)).withIcon(getResources().getDrawable(R.drawable.profile)) 
       ) 
       .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { 
        @Override 
        public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) { 
         //Any activity or Intent 
        } 
       }) 
       .build(); 
     //Create the drawer and remember the `Drawer` result object 
     Drawer result = new DrawerBuilder() 
       .withActivity(this) 
       .withAccountHeader(headerResult) 
       .withToolbar(toolbar) 
       .addDrawerItems(
         item1, item2, item3, item4, item5, item6, 
         new SectionDrawerItem().withName("Extras"), 
         item7, item8, item9, item10 
       ) 

       //Set onClick options for drawer item click 
       .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
        @Override 
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
         // do something with the clicked item :D 
         switch (position) { 
          //Home 
          case 1: { 
           break; 
          } 
          //Login 
          case 2: { 

           //Login Activity 
           break; 
          } 

          case 3: { 
           //Third activity 
           break; 
          } 

          case 4: { 
           break; 
          } 

          case 5: { 

           break; 

          } 
          //Location 
          case 6: { 

           break; 
          } 
          //About us 
          case 8: { 
           break; 
          } 
          //Contact Us 
          case 9: { 

           break; 
          } 
          //Feedback 
          case 10: { 

           break; 
          } 
          //Settings 
          case 11:{ 

           break; 
          } 

         } 
         return true; 
        } 
       }) 
       .build(); 

     result.addStickyFooterItem(new PrimaryDrawerItem().withName("Visit us again")); //Adding footer to nav drawer 
    } 

アンドロイドスタジオのbuild.gradleファイルに次の行を追加する必要があります。

compile('com.mikepenz:materialdrawer:[email protected]') { 
    transitive = true 
} 
compile 'com.mikepenz:fontawesome-typeface:[email protected]' 
関連する問題