2
我有一個Activity
其中包含3 Fragment
s。其中所有的3 Fragment
都有ListView
。如何在滾動ListView中顯示具有3個片段的Activity?
我想知道如何在同Activity
中顯示3 Fragment
s在ScrollView
?
請讓我知道解決方案。
謝謝。
我有一個Activity
其中包含3 Fragment
s。其中所有的3 Fragment
都有ListView
。如何在滾動ListView中顯示具有3個片段的Activity?
我想知道如何在同Activity
中顯示3 Fragment
s在ScrollView
?
請讓我知道解決方案。
謝謝。
所以我認爲這裏的正確用戶體驗是隻有1個滾動視圖,即基本滾動視圖。然後,片段中的列表視圖應該擴展爲佔用儘可能多的空間。
我做到了這一點的方式是覆蓋onMeasure這樣
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {
/**
* Putting things which like to be scrolled into scrolling views causes bad behavior.
*
* The goal here is to simply trick the List view into believing it should fill all available
* space rather than being undefined.
*/
heightMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
這種方式,你有1個滾動視圖,你有3個擴展列表視圖。
你試過了甚麼?你不能在ScrollView中使用ListView。 – 2014-11-22 06:57:25
http://stackoverflow.com/questions/4949216/using-multiple-fragments-in-an-single-activity – Riad 2014-11-22 07:00:49
不,我沒有使用滾動列表只是列表視圖 – 2014-11-22 07:01:36