开发者

Custom TabHost- problem Handling childs added in XML

I have built a custom component, which extends TabHost and adds the needed TabwWidget and FrameLayout with the required Ids by default.

This works just fine, but I would like to handle the childs defined in an xml file.

<my.custom.TabHost>
    <LinearLayout android:id="@+id/layout"></LinearLayout>          
</my.custom.TabHost>

If its defined like this I would like to automatically call a method which makes a TabSpec from the View and adds it to the TabHost.

But I dont know when the children are added to the View, so I dont know where to check if I should add the Views normally, or make a TabSpec out of it.

Is there a way to achieve this?

After Constructor just the 2 default Children(TabWidget, FrameLayout) are added, childcount is 2.

After onlayout, childCount is 3. But which methoid is called between?

I checked开发者_运维问答 addVIewInLayout, but still no effect.

Any help is appreciated.


I solved it myself. It was so simple, I didn't check this first ;-)

Just override all methods of addview, and check in them if it is one of the Two required Views for TabHost, and then call super.addView(), otherwise create the TabSpec from the View and add it via addTab().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜