我的应用程序基于选项卡式布局,其中每个选项卡都指定了FragmentActivity。
一个这种活动的具有以下布置:ListView在后台接收输入(Fragment API)
<FrameLayout
android:id="@+id/filialenView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:layout_height="wrap_content" android:id="@+id/filialList"
android:layout_width="fill_parent"></ListView>
</FrameLayout>
当切换到该标签时,将创建的列表和示出。
如果选择了一个列表项,则创建一个片段,并显示在列表的顶部:
Filiale fragment = new Filiale();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.filialenView, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
布局“filial_detail.xml”为片段分公司看起来像
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
... content...
</LinearLayout>
和在这样的onCreateView中这样膨胀
View curView = inflater.inflate(R.layout.filial_detail, container, false);
一切都像预期的那样工作,除了在s对片段的虚惊,名单上的可见清单似乎保持了输入焦点。如果我在某个“空白”区域触摸屏幕,触发片段后面的隐藏列表项。另外,如果我滑动,我可以从LogCat输出中看到该列表滚动。
基于我对FrameLayout的理解,应该可以像这样堆叠视图。
该代码有什么问题?
由于目前还没有答案或评论,所以还有一个更一般的问题:
是否有任何已知的情况,即背景中的视图应该接收输入,或者在任何情况下都是错误的行为?
1为的高度来实现视图组的启示默认情况下不处理输入事件。 – 2014-07-30 09:18:01