Thanks for the help. I didn't actually manage it this way, but somehow i saw the *createTabContent* function from *TabContentFactory* (which i was already using actually) is called every time a tab is selected, not just at its creation. So i make a completely new *LinearLayout* inside the tab and just return it as the content, being able to do whatever i want in that * LinearLayout*.
Thanks for the help again. On Fri, Aug 22, 2008 at 7:20 PM, Josh Guilfoyle <[EMAIL PROTECTED]> wrote: > > This seems a bit goofed up to me. First off, the FrameLayout holding > your tabs should initially be empty. the TabHost will manage filling > it in with the contents of the tab you've selected. > > addTouchables is very certainly not what you want. You want to use > addView() but make sure that the view you get with getCurrentView is > what you expect. Make one tab have a <LinearLayout> with android:id="@ > +id/foobarbaz", then check that getCurrentView hands you a view for > which findViewById(R.id.foobarbaz) succeeds to find your > LinearLayout. If not, try getCurrentTabView (there is nod > ocumentation, so we're just stabbing in the dark here). The other > solution is to better abstract the tab content in question and let the > abstractions manage themselves. You can do this by separating the > content of each tab into its own Activity and properly isolate them > that way. When you click some button in Activity A, A can manage > adding views to its layout entirely on its own. > > On Aug 21, 11:48 pm, Teo <[EMAIL PROTECTED]> wrote: > > Ok, great, thanks for the help! Here's the relevant code from the XML: > > > > *<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android > " > > android:orientation="vertical" > > android:layout_width="fill_parent" > > android:layout_height="fill_parent"> > > <TabHost android:id="@+id/tabhost" > > android:layout_width="fill_parent" > > android:layout_height="fill_parent"> > > <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" > > android:paddingTop="62px"> > > <Button android:id="@+id/buttontab" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:text="A semi-random button" > > /> > > </FrameLayout> > > </TabHost> > > </LinearLayout>* > > > > And here's how i tried to add something: > > > > * private void addItem(){ > > CheckBox c=new CheckBox(this); > > ArrayList<View> a=new ArrayList<View>(); > > a.add(c); > > tabs.getCurrentView().addTouchables(a); > > }* > > > > *tabs* is the TabHost object. > > > > Did i get it wrong with the *addTouchables*? I couldn't find any better > > method. Also, instead of *getCurrentView* i tried *getCurrentTabView* and > i > > also tried a lot of casts applied to children and children of children > and i > > couldn't get an effect. > > > > (I know the function above is called when it should be - i confirmed it > > during debug..) > > > > Thanks, > > Teo > > > > > > > > On Fri, Aug 22, 2008 at 12:06 AM, Josh Guilfoyle <[EMAIL PROTECTED]> > wrote: > > > > > Actually my mistake. getCurrentTabView might just get the view of the > > > tab you have selected (not the contents of the tab). Try > > > getCurrentView. Post sample code if you can't get it working and I > > > will explore further. > > > > > On Aug 21, 2:04 pm, Josh Guilfoyle <[EMAIL PROTECTED]> wrote: > > > > Do you mean to add a new tab or simply dynamically adjust the View > > > > hierarchy in a particular tab? If so, getCurrentTabView will work to > > > > do what you need. Just modify the view hierarchy found there. Do > > > > realize that you are getting the root-level View of the tab, so you > > > > must search within that using View#findViewById to locate the actual > > > > view you're looking to modify. > > > > > > On Aug 21, 11:28 am, Teo <[EMAIL PROTECTED]> wrote: > > > > > > > Hi, > > > > > > > i tried debugging quite a bit, but i can't figure it out; is it > > > > > possible to add something (buttons, etc.) to a tab? I'm using a > > > > > FrameLayout inside a TabWidget inside a TabHost. I tried lots of > > > > > things, including adding to TabHost's getCurrentTabView, but i > wasn't > > > > > lucky. > > > > > > > Any tips? > > > > > > > Thanks, > > > > > Teo > > > > -- > > Teo (a.k.a. Teodor Filimon, Teominator) > > Site -www.teodorfilimon.com| Blog -www.teodorfilimon.blogspot.com > > GMT +2 (or PDT +10) > > > -- Teo (a.k.a. Teodor Filimon, Teominator) Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com GMT +2 (or PDT +10) --~--~---------~--~----~------------~-------~--~----~ 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] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

