Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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:
- MainActivity :
- btnMenu.setVisibility(View.VISIBLE);
- homeScreenFragment = new HomeScreenFragment();
- getSupportFragmentManager().beginTransaction()
- .replace(R.id.frameLayout, homeScreenFragment).commit();
- // configure the SlidingMenu menu = new SlidingMenu(this);
- menu=new SlidingMenu(this);
- menu.setShadowDrawable(R.drawable.shadow);
- menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
- menu.setFadeDegree(0.35f);
- menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
- menu.setMenu(R.layout.menu_frame);
- getSupportFragmentManager().beginTransaction()
- .replace(R.id.menu_frame, new HomeNavFragment()).commit();
- findViewById(R.id.imgBtnMenu).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- menu.toggle(true);
- }
- });
- public final String[] podName = new String[] { "NO Text", "NO Text",
- "NO Text", "NO Text" };
- public final Integer[] images = { R.drawable.pod_img1, R.drawable.pod_img2,
- R.drawable.pod_img3, R.drawable.pod_img1 };
- @Override
- public void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.layout_homescreen, container,
- false);
- ButterKnife.inject(this, view);
- return view;
- }
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onActivityCreated(savedInstanceState);
- addItemsToListView();
- }
- private void addItemsToListView() {
- rowItems = new ArrayList<RowItem>();
- for (int i = 0; i < podName.length; i++) {
- RowItem item = new RowItem(images[i], podName[i]);
- // RowItem item = new RowItem(imageUrl[i], deityName[i]);
- rowItems.add(item);
- }
- setAdapter();
- }
- private void setAdapter() {
- CustomBaseAdapter adapter = new CustomBaseAdapter(getActivity(), rowItems);
- podListView.setAdapter(adapter);
- }
- Navigation Fragment:
- public static final int[] nav_icon = { R.drawable.ic_menu_calender,
- R.drawable.ic_menu_roster, R.drawable.ic_menu_publication,
- R.drawable.ic_menu_filebox, R.drawable.ic_menu_court,
- R.drawable.ic_menu_bubble, R.drawable.ic_menu_profile,
- R.drawable.ic_menu_reminder, R.drawable.ic_menu_share,
- R.drawable.ic_menu_developer, R.drawable.ic_menu_developer,
- R.drawable.ic_menu_developer };
- @Override
- public void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.layout_homescreen, container,
- false);
- ButterKnife.inject(this, view);
- return view;
- }
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onActivityCreated(savedInstanceState);
- setAdapter();
- /*addItemsToListView();*/
- }
- private void setAdapter() {
- NavigationMenuAdapter adapter = new NavigationMenuAdapter(getActivity(),nav_title,nav_icon);
- podListView.setAdapter(adapter);
- }
- Xml:
- layout_home:
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- <include
- android:id="@+id/header_home"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- layout="@layout/include_header" />
- <FrameLayout
- android:id="@+id/frameLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@+id/header_home">
- </FrameLayout>
- </RelativeLayout>
- layout_homescreen
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <ListView
- android:id="@+id/podListView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:cacheColorHint="@android:color/transparent"
- android:listSelector="@android:color/transparent" >
- </ListView>
- </LinearLayout>
- menu.xml
- <?xml version="1.0" encoding="utf-8"?>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/menu_frame"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement