0

I am using this lib for my sliding menu. I am not able to slide, if I make a simple Fragment and swipe. Here is the code. The code fails if I use MapFragment. if I add SampleListFragment() instead of MapFragment it works fine.

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setTitle("Testing");

        setContentView(R.layout.content_frame);
        getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.content_frame, new Mapfragment())
        .commit();
        //.beginTransaction().commit();
        //.replace(R.id.content_frame, new SampleListFragment())
//  .commit();

        menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.LEFT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        menu.setShadowWidthRes(R.dimen.shadow_width);
        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 SampleListFragment())
        .commit();
    }

My MapFragment code.

public class Mapfragment extends SherlockFragment{

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_main, null);
    }

Activity_main code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

</RelativeLayout>

Here is my content_frame code,

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Could you please tell where the mistake is.

Kriem
  • 8,666
  • 16
  • 72
  • 120
Naruto
  • 9,476
  • 37
  • 118
  • 201
  • You may want to use MapFragments instead of sherlock fragment as described [here](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment) though it requires google play service be installed on the device. – zoya ali Mar 07 '13 at 18:16
  • Can you give some explanation for Switching fragment while clicking on slide menu list. @LLL – Pratik Butani May 09 '13 at 07:25
  • Switching fragment means?, can you elaborate the scenario to some more.. – Naruto May 09 '13 at 08:04

0 Answers0