我的應用程序基於選項卡式佈局,其中每個選項卡都指定了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