我正在使用jfeinstein10 / SlidingMenu进行滑动菜单我希望在片段中选择矩形按钮时更改菜单项的内容 当尝试使用switchcontent用新片段替换内容时,我得到像这样的错误
> 04-03 13:02:20.093: E/AndroidRuntime(6498): FATAL EXCEPTION: main
04-03 13:02:20.093: E/AndroidRuntime(6498): java.lang.IllegalStateException: Activity has been destroyed
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1342)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
04-03 13:02:20.093: E/AndroidRuntime(6498): at com.akiland.slidingmenuexample.MainActivity.switchContent1(MainActivity.java:82)
04-03 13:02:20.093: E/AndroidRuntime(6498): at other.PipeSel$1.onItemClick(PipeSel.java:47)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.widget.AbsListView$1.run(AbsListView.java:3423)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.os.Handler.handleCallback(Handler.java:725)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.os.Handler.dispatchMessage(Handler.java:92)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.os.Looper.loop(Looper.java:137)
04-03 13:02:20.093: E/AndroidRuntime(6498): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-03 13:02:20.093: E/AndroidRuntime(6498): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 13:02:20.093: E/AndroidRuntime(6498): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 13:02:20.093: E/AndroidRuntime(6498): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-03 13:02:20.093: E/AndroidRuntime(6498): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-03 13:02:20.093: E/AndroidRuntime(6498): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
您将进行布局仪式的菜单?在这种情况下,在主菜单布局中有两个布局/视图。有一个布局/视图的可见性,View.Vone和其他的View.Gone。单击按钮单击时,切换布局/视图的可见性
答案 1 :(得分:0)
通过
解决了更改的菜单内容getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.menu_frame,fragment)
.commit();
}
片段上的