开发者

TabHost setBackgroundResource yields blank tabs

开发者 https://www.devze.com 2023-04-01 22:13 出处:网络
I\'m using: intent = new Intent().setClass(this,MoreActivityGroup.class); // Initialize a TabSpec for each tab and add it to the TabHost

I'm using:

intent = new Intent().setClass(this,MoreActivityGroup.class);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabHost.newTabSpec("more").setIndicator("").setContent(intent);
    tabHost.addTab(spec);
    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
    {
        tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_feed_unselected_mdpi);
        tabHost.getTa开发者_开发知识库bWidget().getChildAt(i).invalidate();

    }

But all my tabs are blank, with just a little grey box at the bottom. Why does this not work? My goal is to have complete custom tabs without any of Android's default graphics


   ImageView selTab = (ImageView) tabHost.getTabWidget().getChildTabViewAt(sel).findViewById(R.id.single_tab_img);

   selTab.setImageResource(selected_img[sel]);


Check this tutorial, it was very useful to me and I have 100% customed tabs: http://ondrejcermak.info/en/programovani/custom-tabs-in-android-tutorial/

0

精彩评论

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