Android幻灯片菜单无法替换片段

Android幻灯片菜单无法替换片段,android,android-fragments,Android,Android Fragments,我尝试创建幻灯片菜单。编写的代码可以显示/隐藏幻灯片菜单,但现在我想替换listview中的片段单击侦听器。单击listview时,无法替换片段 这是我的Xml代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" >

我尝试创建幻灯片菜单。编写的代码可以显示/隐藏幻灯片菜单,但现在我想替换listview中的片段单击侦听器。单击listview时,无法替换片段

这是我的Xml代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.coboltforge.slidemenu.SlideMenu
        android:id="@+id/slideMenu"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </com.coboltforge.slidemenu.SlideMenu>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/buttonMenu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/menubutton" />

        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/buttonMenu"
            android:background="#ff0000" >
        </FrameLayout>
    </RelativeLayout>

</RelativeLayout>

有什么错误吗?尝试检查位置是否正确。添加Log.dtest,位置:+position;并检查Logcat中是否显示了正确的数字。我认为您正在onSlideMenuItemClick中获取视图id,因为您正在检查开关箱中的位置。在日志中打印位置,上面写着什么?
@Override
public void onSlideMenuItemClick(int itemId) {

    navigateTo(itemId);


}


private void navigateTo(int position) {

    switch (position) {
    case 0:

        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.content_frame,
                        StradaBooking.newInstance(),
                        StradaBooking.TAG).commit();
        break;
    case 1:
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.content_frame, StradaContact.newInstance(),
                        StradaContact.TAG).commit();
        break;

    case 2:
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.content_frame, StradaBooking.newInstance(),
                        StradaBooking.TAG).commit();
        break;

    case 3:
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.content_frame, StradaContact.newInstance(),
                        StradaContact.TAG).commit();
        break;
    }
}