2017-11-04 1 views
-1

탐색 용 서랍의 두 항목 사이에 테두리를 추가하려고합니다. Navieragation 서랍 용 Mikepenz 자재 서랍 (https://github.com/mikepenz/MaterialDrawer)을 사용했습니다.탐색 서랍의 항목 사이에 테두리를 추가하는 방법은 무엇입니까?

다음은 스크린 샷입니다. 내가이 줄을 추가 한

screen

: 난 그냥 "다운로더"와 "공유 및 속도"와 같은 제목 것은

여기에 스크린 샷을 살펴보십시오 것을 싶지 않는, 탐색 창에서 그 경계선을 원하는 내 주요 활동 다운로더 등을 차별화하기 :. 새로운 SectionDrawerItem() withName (R.string.drawer_item_section_header), 여기에

탐색 서랍 내 자바 코드 :

//Navigation Drawer 
    headerResult = new AccountHeaderBuilder() 
      .withActivity(this) 
      .withHeaderBackground(R.color.colorPrimary) 
      .withSelectionListEnabledForSingleProfile(false) 
      .withAlternativeProfileHeaderSwitching(false) 
      .withCompactStyle(false) 
      .withDividerBelowHeader(false) 
      .withProfileImagesVisible(true) 
      .withTypeface(typeface) 
      .addProfiles(new ProfileDrawerItem().withIcon(R.mipmap.ic_launcher).withName(getResources().getString(R.string.app_name)).withEmail(getResources() 
        .getString(R.string.developer_email))) 
      .build(); 
    resultDrawer = new DrawerBuilder() 
      .withActivity(this) 
      .withSelectedItem(-1) 
      .withFullscreen(true) 
      .withAccountHeader(headerResult) 
      .withActionBarDrawerToggle(true) 
      .withCloseOnClick(true) 
      .withMultiSelect(false) 
      .withTranslucentStatusBar(true) 
      .withToolbar(mToolbar) 
      .addDrawerItems(
        new PrimaryDrawerItem().withSelectable(false).withName(R.string.app_name).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("Downloads").withIcon(R.drawable.ic_inst).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          if (placeholderLayout.getVisibility() == View.VISIBLE) { 
           placeholderLayout.setVisibility(View.GONE); 
           recyclerLayout.setVisibility(View.VISIBLE); 
           setUpRecyclerView(); 
          } 
          return false; 
         } 
        }).withTypeface(typeface), 


        new SectionDrawerItem().withName(R.string.drawer_item_section_header), 


        new PrimaryDrawerItem().withSelectable(false).withName("Story Downloader").withIcon(R.drawable.ic_whatshot_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          Intent intent = new Intent(MainActivity.this,SplashActivity.class); 
          startActivity(intent); 
          return false; 
         } 
        }).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("WhatsApp Downloader").withIcon(R.drawable.ic_wapp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          Intent intent = new Intent(MainActivity.this,WaActivity.class); 
          startActivity(intent); 
          return false; 
         } 
        }).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("Twitter Downloader").withIcon(R.drawable.ic_tweet).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          Intent intent = new Intent(MainActivity.this,TweetActivity.class); 
          startActivity(intent); 
          return false; 
         } 
        }).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("Facebook Downloader").withIcon(R.drawable.ic_facebook_logo).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          Intent intent = new Intent(MainActivity.this,FbActivity.class); 
          startActivity(intent); 
          return false; 
         } 
        }).withTypeface(typeface), 

        new SectionDrawerItem().withName(R.string.drawer_item_section_share), 

        new PrimaryDrawerItem().withSelectable(false).withName("Recommend to Friends").withIcon(R.drawable.ic_share_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          final String shareappPackageName = getPackageName(); 
          Intent sendIntent = new Intent(); 
          sendIntent.setAction(Intent.ACTION_SEND); 
          sendIntent.putExtra(Intent.EXTRA_TEXT, "Check out Social Downloader App at: https://play.google.com/store/apps/details?id=" + shareappPackageName); 
          sendIntent.setType("text/plain"); 
          startActivity(sendIntent); 
          return false; 
         } 
        }).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("Rate Us").withIcon(R.drawable.ic_thumb_up_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          final String appPackageName = getPackageName(); 
          try { 
           startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); 
          } catch (ActivityNotFoundException anfe) { 
           startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); 
          } 
          return false; 
         } 
        }).withTypeface(typeface), 



        new PrimaryDrawerItem().withSelectable(false).withName("Help").withIcon(R.drawable.ic_help_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          Intent intent = new Intent(MainActivity.this, IntroActivity.class); 
          startActivity(intent); 
          return false; 
         } 
        }).withTypeface(typeface), 


        new PrimaryDrawerItem().withSelectable(false).withName("Privacy Policy").withIcon(R.drawable.ic_info_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          AlertDialog dialog = new AlertDialog.Builder(MainActivity.this) 
            .setTitle("PRIVACY POLICY") 
            .setMessage(R.string.privacy_message) 
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { 
             public void onClick(DialogInterface dialog, int which) { 
              dialog.dismiss(); 
             } 
            }) 
            .setIcon(R.drawable.ic_info_black_24dp) 
            .show(); 
          TextView textView = (TextView) dialog.findViewById(android.R.id.message); 
          textView.setScroller(new Scroller(MainActivity.this)); 
          textView.setVerticalScrollBarEnabled(true); 
          textView.setMovementMethod(new ScrollingMovementMethod()); 
          return false; 
         } 
        }).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("Feedback").withIcon(R.drawable.ic_feedback_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          DisplayMetrics displaymetrics = new DisplayMetrics(); 
          getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); 
          int height = displaymetrics.heightPixels; 
          int width = displaymetrics.widthPixels; 
          PackageManager manager = getApplicationContext().getPackageManager(); 
          PackageInfo info = null; 
          try { 
           info = manager.getPackageInfo(getPackageName(), 0); 
          } catch (PackageManager.NameNotFoundException e) { 
           // TODO Auto-generated catch block 
           e.printStackTrace(); 
          } 
          String version = info.versionName; 
          Intent i = new Intent(Intent.ACTION_SEND); 
          i.setType("message/rfc822"); 
          i.putExtra(Intent.EXTRA_EMAIL, new String[]{getResources().getString(R.string.developer_email)}); 
          i.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name) + version); 
          i.putExtra(Intent.EXTRA_TEXT, 
            "\n" + " Device :" + getDeviceName() + 
              "\n" + " System Version:" + Build.VERSION.SDK_INT + 
              "\n" + " Display Height :" + height + "px" + 
              "\n" + " Display Width :" + width + "px" + 
              "\n\n" + "Have a problem? Please share it with us and we will do our best to solve it!" + 
              "\n"); 
          startActivity(Intent.createChooser(i, "Send Email")); 
          return false; 
         } 
        }).withTypeface(typeface), 
        new PrimaryDrawerItem().withSelectable(false).withName("Exit").withIcon(R.drawable.ic_exit_to_app_black_24dp).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
         @Override 
         public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
          finish(); 
          return false; 
         } 
        }).withTypeface(typeface) 
      ). 
        withSavedInstance(savedInstanceState) 
      .build(); 
    loadInterstitialAd(); 
} 
+0

안녕하세요. 해당 스크린 샷에 대한 링크가 포함되도록 질문을 수정하고 코드 서식을 수정하십시오. ... 여전히 지저분 해 보인다. – yacc

+0

@yacc 나는 왜 이렇게 생겼는지 모르겠다. 코드 붙여 넣기 만 했어. 그것의 절반은 좋게 보이고 다른 것은 엉망진창입니다, 나는 미안하지만 나는 여기서 새로운 것입니다. 그리고 나는 SO에 formating에 대해 전혀 모른다. –

+0

[This] (https://github.com/mikepenz/MaterialDrawer/blob/develop/README.md)를 읽으십시오. – ADM

답변

0

는 일반적으로 당신은 당신의 메뉴 XML 파일에서 작업을 수행해야합니다 단순히 (각 그룹이 분할로 구분됩니다)

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android"> 
    <group 
     android:id="@+id/item1"> 
     <item 
      android:id="@+id/nav_settings" 
      android:icon="@drawable/ic_settings" 
      android:title="Settings"/> 
    </group> 
<group 
     android:id="@+id/item2"> 
     <item 
      android:id="@+id/nav_info" 
      android:icon="@drawable/ic_info" 
      android:title="Info"/> 
    </group> 
</menu> 

, 각 그룹 ID를 가지고 있어야합니다 별도의 그룹에서 각 메뉴 항목을 넣어 업데이트 :

방금 ​​사용한 서랍의 github을 확인했습니다. 나는 그것에 익숙하지 않은,하지만 난 방법을 발견 :

result.addItem(new DividerDrawerItem()); 

어쩌면 그것은, 미안 해요 더 도움이되지 수 있습니다 도움이 될 것입니다,하지만 당신은 아마 당신이 문서화에 자신의 소스 코드 예제에 필요한 모든 것을 찾을 것

+0

고마워. 너희들은 매우 도움이된다. 하지만 자바 코드에서 이것을 원한다. Java 코드에서 모든 것을했기 때문입니다. –

+0

오, 알았어, 내가 사용했던 서랍의 github을 확인했다. 나는 그것에 익숙하지 않지만 메서드를 발견했다 : result.addItem (new DividerDrawerItem()); –

관련 문제