문제

I'm working on an Android application with an activity that uses a tab layout. There are two tabs which switch between the content being shown in a ListView below.

This means that the two tab specifications point to the same ListView for content, R.id.main_list:

<TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" />

<FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent">

     <ListView 
          android:id="@+id/main_list" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" />
 </FrameLayout>

This somewhat works - if I switch to tab #2 and back to #1, I can see the ListView and my database code gets the right data based on the selected tab. However, when the activity launches, the ListView can't be seen before tabs are changed. This is obviously a problem.

What's the least hacky way to get around this?

도움이 되었습니까?

해결책

Use two ListView widgets.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top