Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. private void createNavDrawerItems() {
  2. mDrawerItemsListContainer = (ViewGroup) findViewById(R.id.navdrawer_items_list);
  3. ...
  4. int i = 0;
  5. for (int itemId : mNavDrawerItems) {
  6. mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, mDrawerItemsListContainer);
  7. mDrawerItemsListContainer.addView(mNavDrawerItemViews[i]);
  8. ++i;
  9. }
  10. }
  11.  
  12. private View makeNavDrawerItem(final int itemId, ViewGroup container) {
  13. ...
  14. if (itemId == NAVDRAWER_ITEM_SEPARATOR) {
  15. layoutToInflate = R.layout.navdrawer_separator;
  16. } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) {
  17. layoutToInflate = R.layout.navdrawer_separator;
  18. } else {
  19. layoutToInflate = R.layout.navdrawer_item;
  20. }
  21. ...
  22. return view;
  23. }
  24.  
  25. <android.support.v4.widget.DrawerLayout
  26. xmlns:android="http://schemas.android.com/apk/res/android"
  27. xmlns:app="http://schemas.android.com/apk/res-auto"
  28. android:layout_width="match_parent"
  29. android:layout_height="match_parent"
  30. android:fitsSystemWindows="true">
  31.  
  32. <!-- your content layout -->
  33.  
  34. <android.support.design.widget.NavigationView
  35. android:layout_width="wrap_content"
  36. android:layout_height="match_parent"
  37. android:layout_gravity="start"
  38. app:headerLayout="@layout/drawer_header"
  39. />
  40. </android.support.v4.widget.DrawerLayout>
  41.  
  42. <LinearLayout
  43. xmlns:android="http://schemas.android.com/apk/res/android"
  44. android:layout_width="match_parent"
  45. android:layout_height="wrap_content"
  46. android:choiceMode="singleChoice"
  47. android:orientation="vertical">
  48.  
  49. <TextView
  50. android:id="@+id/myFirstButton"
  51. android:onClick="onMyFirstButtonClick"
  52. android:text="@string/my_first_button_title"/>
  53.  
  54. <TextView
  55. android:id="@+id/goToTheTopButton"
  56. android:onClick="onGoToTheTopButtonClick"
  57. android:text="@string/go_to_the_top_title"/>
  58.  
  59. <View style="@style/Divider"/>
  60.  
  61. <!-- Some other "menu items" -->
  62. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement