Hi Justin,

Yes, you are right.  I went too fast in my reply.  I did indeed make the 
two calls and it did indeed work.
I was wanting to limit the number of resources needed in this activity - 
where in my use of one unique ListView.

After this short discussion, I think I will try to use a single list view 
per tab and see what the performance hit will be.


On Wednesday, 20 June 2012 18:09:56 UTC+2, MagouyaWare wrote:
>
> If I call tabhost.setCurrentTab(1) instead of tabhost.setCurrentTab(0), 
>> then the initial display is correct.
>>
>
> I think you misunderstood me... I wanted you to call both of them... 
> First, set the current tab to 1 and then to 0...  Does the listview display 
> correctly on tab 0 if you do this?  My guess is that it would.  This is 
> probably not the best way to solve the problem though, but would work be a 
> potential workaround if all else fails.
>
> To answer your question, the OnTabChangedListener code rebuilds the 
>> listview content.
>>
>
> I noticed you are setting the OnTabChangedListener after setting the 
> current tab... What happens if you try setting the change listener first?  
> You may need to verify that this method gets called when you do this... if 
> the tab host defaults the current tab to 0 and then you set it to 0 it may 
> decide it doesn't need to do anything... In which case, you would need to 
> call the method for a tab change manually yourself first.
>
> To answer @Mark Murphy (a Commons Guy), when I subsequently click through 
>> the tabs, the single listview is correctly updated and displayed.
>> It just doesn't display correctly upon initial display.
>>
>
> Just because it seems to work doesn't mean it is actually supported.  If 
> this is not the intended way to use a tabhost then it may just work as a 
> side-effect of other things, but you may see weirdness as a result of it... 
> If this isn't supposed to be supported then the devs likely have not tested 
> this scenario...
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Wed, Jun 20, 2012 at 10:00 AM, Simon Giddings wrote:
>
>> Wow, I hadn't expected replies so quickly !
>>
>> @MagouyaWare - To answer your question, the OnTabChangedListener code 
>> rebuilds the listview content.
>> I have indeed stepped through this to ensure that it does this correctly 
>> before the first display.
>>
>> If I call tabhost.setCurrentTab(1) instead of tabhost.setCurrentTab(0), 
>> then the initial display is correct.
>>
>> To answer @Mark Murphy (a Commons Guy), when I subsequently click 
>> through the tabs, the single listview is correctly updated and displayed.
>> It just doesn't display correctly upon initial display.
>>
>>
>> On Wednesday, 20 June 2012 17:47:15 UTC+2, MagouyaWare wrote:
>>
>>> Also, what does your OnTabChangedListener code do?
>>>
>>> Thanks,
>>> Justin Anderson
>>> MagouyaWare Developer
>>> http://sites.google.com/site/**magouyaware<http://sites.google.com/site/magouyaware>
>>>
>>>
>>> On Wed, Jun 20, 2012 at 9:46 AM, Justin Anderson wrote:
>>>
>>>>  Just out of curiosity, try doing this:
>>>>
>>>> *tabhost.setCurrentTab(1);
>>>> tabhost.setCurrentTab(0);
>>>> *
>>>> Does your list show up at that point?
>>>>
>>>> Thanks,
>>>> Justin Anderson
>>>> MagouyaWare Developer
>>>> http://sites.google.com/site/**magouyaware<http://sites.google.com/site/magouyaware>
>>>>
>>>>
>>>>
>>>> On Wed, Jun 20, 2012 at 9:41 AM, Simon Giddings  wrote:
>>>>
>>>>> I have a TabActivity containing a series of four tabs and a listview.
>>>>> Each of the tabs reference the same listview.
>>>>> When the activity is initially displayed, the listview is not 
>>>>> displayed.
>>>>> However, clicking on another tab will display it correctly and 
>>>>> clicking back on the first tab will also display it correctly.
>>>>> The content of the listview is changed depending on the selected tab.
>>>>>
>>>>> Here is my XML layout :
>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>> <TabHost 
>>>>> xmlns:android="http://schemas.**android.com/apk/res/android<http://schemas.android.com/apk/res/android>
>>>>> "
>>>>>     android:id="@android:id/**tabhost"
>>>>>     android:layout_width="match_**parent"
>>>>>     android:layout_height="match_**parent" >
>>>>>     
>>>>>     <LinearLayout
>>>>>         android:layout_width="fill_**parent"
>>>>>         android:layout_height="fill_**parent"
>>>>>         android:orientation="vertical" >
>>>>>         
>>>>>         <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/**listPoisFound"
>>>>>                 android:layout_width="match_**parent"
>>>>>                 android:layout_height="wrap_**content" >
>>>>>             </ListView>
>>>>>             
>>>>>         </FrameLayout>
>>>>>     </LinearLayout>
>>>>>
>>>>> </TabHost>
>>>>>
>>>>> The tabs are initialised like this :
>>>>>         TabHost tabhost = null;
>>>>>         TabHost.TabSpec spec = null;
>>>>>         // get the tabhost
>>>>>         tabhost = getTabHost();
>>>>>         
>>>>>         // create the individual tabs
>>>>>         spec = tabhost.newTabSpec("first");
>>>>>         spec.setIndicator("First");
>>>>>         spec.setContent(R.id.list);
>>>>>         tabhost.addTab(spec);
>>>>>         
>>>>>         spec = tabhost.newTabSpec("second");
>>>>>         spec.setIndicator("Second");
>>>>>         spec.setContent(R.id.list);
>>>>>         tabhost.addTab(spec);
>>>>>         
>>>>>         spec = tabhost.newTabSpec("third");
>>>>>         spec.setIndicator("Third");
>>>>>         spec.setContent(R.id.list);
>>>>>         tabhost.addTab(spec);
>>>>>         
>>>>>         spec = tabhost.newTabSpec("fourth");
>>>>>         spec.setIndicator("Fourth");
>>>>>         spec.setContent(R.id.list);
>>>>>         tabhost.addTab(spec);
>>>>>         
>>>>>         tabhost.setCurrentTab(0);
>>>>>         
>>>>>         tabhost.**setOnTabChangedListener(this);
>>>>>
>>>>> Has anyone come across this problem ?
>>>>> What is the solution ?
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Android Developers" group.
>>>>> To post to this group, send email to android-developers@**
>>>>> googlegroups.com <[email protected]>
>>>>> To unsubscribe from this group, send email to
>>>>> android-developers+**[email protected]<android-developers%[email protected]>
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>>
>>>>
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to