【发布时间】:2015-07-05 00:33:42
【问题描述】:
我正在尝试在添加片段时让弹出菜单正常工作。 所以,感谢这段代码,我有一个弹出菜单:
https://github.com/garuma/FlyOutMenu/tree/master/FlyOutMenu
<com.myApp.FlyOutContainer xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/FlyOutContainer">
<include
layout="@layout/menu_layout"
android:id="@+id/menu_layout" />
<include
layout="@layout/content_layout"
android:id="@+id/content_layout" />
</comm.myApp.FlyOutContainer>
在我的应用程序开始时,content_layout 由以下布局组成:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
layout="@layout/top_bar_layout"
android:id="@+id/top_bar_layout" />
<include
layout="@layout/root_layout"
android:id="@+id/root_layout" />
</LinearLayout>
启动后,我的activity在root_layout中添加了一个片段:
// Create new fragment and transaction
Fragment questionListFragment = new QuestionListFragment();
FragmentTransaction transaction = FragmentManager.BeginTransaction();
transaction.Add(Resource.Id.root_layout, questionListFragment);
// Commit the transaction
transaction.Commit();
这个新片段包含刷新布局和列表视图的滑动。 当我从左向右滑动时,菜单显示得很好。但是要隐藏它(从右向左滑动),背景中的菜单。
更新:
我认为问题出在 notifyDataSetChanged 上。当菜单打开时,我的视图没有居中,我更新了我的列表视图。因此,在更新时,我的视图被重新创建并重新居中,并且菜单保持在后台...... 我该如何解决?
这里有截图可以理解: (我还不能在 stackOverflow 上发布图片,并且链接不超过 2 个......)
问题来了:
【问题讨论】:
标签: android android-fragments layout xamarin fragment