开发者

Android: in TabWidget, is there a way to get the view containing the tabs?

Hi all I'm trying to write a tab activity in which each of th开发者_运维百科e tabs has a custom view for the indicator. The view is inflated like so:

LayoutInflater inflater = (LayoutInflater)
            context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        specIndicatorView = inflater.inflate(R.layout.tab_indicator, null);

        indicatorIv = (ImageView)specIndicatorView.findViewById(R.id.indicatorImage);
        indicatorTv = (TextView)specIndicatorView.findViewById(R.id.indicatorText);

        indicatorIv.setImageDrawable(context.getResources().getDrawable(indicatorImageRes));
        indicatorTv.setText(indicatorTextRes);

The problem is that the layout parameters that are defined in the child view do not affect it and that is because I don't know how to pass in the parent view to the inflate method.

All I'm trying to do is have an image and some text where the image is aligned to the top and the text is aligned to the bottom of the indicator view but I also need some little tweaks that require me to use this indicator strategy. I've looked at the source of the entire tab mechanism and could not figure out how to get the parent view, do you know how to do it? do you have a better way to achieve what I need?

Thanks


You said you looked through all the code for tabs; what was wrong with just calling getTabWidget() in your activity?


Are you trying to access the TabHost from within one of the tab activities? If so, you should be able to get to the TabHost via getParent() from the child activity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜