2012-06-18 3 views
0

이 샘플을 확장하여 얻은 간단한 앱 (단편 내용이 포함 된 탭)이 있습니다 : http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.html.Android 4.0 : Tab + ListView + 세부 정보 사용시

이러한 탭 중 하나에는 ListView가 있어야하며 항목을 클릭 한 후에는 화면이 작 으면 세부 정보가 표시되고, 화면이 작 으면 세부 정보가 표시되어야합니다 (예 : 가로 모드).

는 여기이 샘플 통합 시도했다 : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentLayout.html을하지만, 하나는 활동이 아니라 조각, 그래서는 사용할 수 없습니다

setContentView(R.layout.fragment_list_layout); 

LE 자세한 내용은 : 내가 가지고있는

을 해당 내용이 단편 인 TabHost가있는 FragmentActivity.

enter image description here

내가를 사용하여이 기능을 얻으려면 : 그 조각 중 하나는 FragmentLayout.java에서이 샘플로, 목록과 같은 화면에 내용을 표시 할 수있는 ListFragment을해야 할 것이다 권장 관행 (탭 내용으로 조각). 이것이 가능한가?

그렇지 않은 경우 특정 탭을 선택하면 다른 FragmentActivity을 시작하려고 시도했습니다. 목표는 이전에 만든 탭 메뉴를 추가 할 수 없다는 점을 제외하고는 FragmentLayout 예제와 마찬가지로 해당 FragmentActivity를 내 레이아웃의 컨테이너 (ListView + 단편)로 사용하는 것입니다. 그러면 어떻게 작동시킬 수 있을까요? 현재

:

enter image description here

"임의 탭"을 선택한 후,

enter image description here

내 최후의 원하는 모양 (원래 tabHost 별도 FragmentActivity) :

enter image description here

답변

0

내 TabContent 내부에 두 개의 컨테이너가있는 문제를 해결했습니다. 하나는 ListView 프래그먼트이고 다른 하나는 세부 정보 조각입니다. 여기 내 레이아웃은 지금 :

<HorizontalScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:scrollbars="vertical" > 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" /> 
</HorizontalScrollView> 

<FrameLayout 
    android:id="@android:id/tabcontent" 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:layout_weight="0" /> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:baselineAligned="false" 
    android:fadingEdge="none" > 

    <FrameLayout 
     android:id="@+android:id/realtabcontent" 
     android:layout_width="0px" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" /> 

    <FrameLayout 
     android:id="@+android:id/details_container" 
     android:layout_width="0px" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:visibility="gone" /> 
</LinearLayout> 

탭이 후 정상적으로 처리 할 수 ​​있습니다.