Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. I am creating a sliding menu drawer in my application...the problem is when i am sliding the menu it is sliding the heading too wheres i just want the content to move with the slider. how can i prevent header from moving. i am using fragments for my code:
  2.  
  3. MainActivity :
  4.  
  5. btnMenu.setVisibility(View.VISIBLE);
  6.  
  7. homeScreenFragment = new HomeScreenFragment();
  8. getSupportFragmentManager().beginTransaction()
  9. .replace(R.id.frameLayout, homeScreenFragment).commit();
  10.  
  11. // configure the SlidingMenu menu = new SlidingMenu(this);
  12. menu=new SlidingMenu(this);
  13.  
  14. menu.setShadowDrawable(R.drawable.shadow);
  15. menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
  16. menu.setFadeDegree(0.35f);
  17. menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
  18. menu.setMenu(R.layout.menu_frame);
  19. getSupportFragmentManager().beginTransaction()
  20. .replace(R.id.menu_frame, new HomeNavFragment()).commit();
  21.  
  22. findViewById(R.id.imgBtnMenu).setOnClickListener(new OnClickListener() {
  23. @Override
  24. public void onClick(View v) {
  25. menu.toggle(true);
  26. }
  27. });
  28.  
  29. public final String[] podName = new String[] { "NO Text", "NO Text",
  30. "NO Text", "NO Text" };
  31.  
  32. public final Integer[] images = { R.drawable.pod_img1, R.drawable.pod_img2,
  33. R.drawable.pod_img3, R.drawable.pod_img1 };
  34.  
  35. @Override
  36. public void onCreate(Bundle savedInstanceState) {
  37. // TODO Auto-generated method stub
  38. super.onCreate(savedInstanceState);
  39. }
  40.  
  41. @Override
  42. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  43. Bundle savedInstanceState) {
  44.  
  45. View view = inflater.inflate(R.layout.layout_homescreen, container,
  46. false);
  47. ButterKnife.inject(this, view);
  48.  
  49. return view;
  50. }
  51.  
  52. @Override
  53. public void onActivityCreated(Bundle savedInstanceState) {
  54. // TODO Auto-generated method stub
  55. super.onActivityCreated(savedInstanceState);
  56.  
  57. addItemsToListView();
  58.  
  59. }
  60.  
  61. private void addItemsToListView() {
  62. rowItems = new ArrayList<RowItem>();
  63. for (int i = 0; i < podName.length; i++) {
  64.  
  65. RowItem item = new RowItem(images[i], podName[i]);
  66. // RowItem item = new RowItem(imageUrl[i], deityName[i]);
  67. rowItems.add(item);
  68. }
  69. setAdapter();
  70. }
  71.  
  72. private void setAdapter() {
  73. CustomBaseAdapter adapter = new CustomBaseAdapter(getActivity(), rowItems);
  74. podListView.setAdapter(adapter);
  75. }
  76.  
  77. Navigation Fragment:
  78.  
  79. public static final int[] nav_icon = { R.drawable.ic_menu_calender,
  80. R.drawable.ic_menu_roster, R.drawable.ic_menu_publication,
  81. R.drawable.ic_menu_filebox, R.drawable.ic_menu_court,
  82. R.drawable.ic_menu_bubble, R.drawable.ic_menu_profile,
  83. R.drawable.ic_menu_reminder, R.drawable.ic_menu_share,
  84. R.drawable.ic_menu_developer, R.drawable.ic_menu_developer,
  85. R.drawable.ic_menu_developer };
  86.  
  87. @Override
  88. public void onCreate(Bundle savedInstanceState) {
  89. // TODO Auto-generated method stub
  90. super.onCreate(savedInstanceState);
  91. }
  92.  
  93. @Override
  94. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  95. Bundle savedInstanceState) {
  96.  
  97. View view = inflater.inflate(R.layout.layout_homescreen, container,
  98. false);
  99. ButterKnife.inject(this, view);
  100.  
  101. return view;
  102. }
  103.  
  104. @Override
  105. public void onActivityCreated(Bundle savedInstanceState) {
  106. // TODO Auto-generated method stub
  107. super.onActivityCreated(savedInstanceState);
  108.  
  109. setAdapter();
  110.  
  111. /*addItemsToListView();*/
  112.  
  113. }
  114.  
  115.  
  116.  
  117. private void setAdapter() {
  118. NavigationMenuAdapter adapter = new NavigationMenuAdapter(getActivity(),nav_title,nav_icon);
  119. podListView.setAdapter(adapter);
  120. }
  121.  
  122. Xml:
  123.  
  124. layout_home:
  125.  
  126.  
  127.  
  128. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  129. android:layout_width="match_parent"
  130. android:layout_height="match_parent" >
  131.  
  132. <include
  133. android:id="@+id/header_home"
  134. android:layout_width="match_parent"
  135. android:layout_height="wrap_content"
  136. android:layout_alignParentTop="true"
  137. layout="@layout/include_header" />
  138.  
  139. <FrameLayout
  140. android:id="@+id/frameLayout"
  141. android:layout_width="match_parent"
  142. android:layout_height="match_parent"
  143. android:layout_below="@+id/header_home">
  144. </FrameLayout>
  145.  
  146. </RelativeLayout>
  147.  
  148. layout_homescreen
  149.  
  150.  
  151.  
  152. <?xml version="1.0" encoding="utf-8"?>
  153. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  154. android:layout_width="match_parent"
  155. android:layout_height="match_parent"
  156. android:orientation="vertical" >
  157.  
  158. <ListView
  159. android:id="@+id/podListView"
  160. android:layout_width="match_parent"
  161. android:layout_height="wrap_content"
  162. android:cacheColorHint="@android:color/transparent"
  163. android:listSelector="@android:color/transparent" >
  164. </ListView>
  165.  
  166. </LinearLayout>
  167.  
  168. menu.xml
  169.  
  170. <?xml version="1.0" encoding="utf-8"?>
  171. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  172. android:id="@+id/menu_frame"
  173. android:layout_width="match_parent"
  174. android:layout_height="match_parent" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement