Question

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?

Was it helpful?

Solution

Use two ListView widgets.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top