图标不会显示在选项卡小部件中



我正在尝试用TabSpec填充TabHost,一切都很好,但是没有显示插入setIndicator(text,drawable)的图标。我尝试使用自己的照片以及来自 android 的照片 - 没有一张有效。

这是我的代码:

tabs = (TabHost)findViewById( android.R.id.tabhost );
tabs.setup();
TabHost.TabSpec spec;
spec = tabs.newTabSpec( "destinationTab" )
           .setContent( R.id.destinationTab )
           .setIndicator( getString( R.string.enter_target ), getResources().getDrawable( android.R.drawable.ic_secure ) );
tabsDef.put( "destinationTab", R.id.destinationTab );
tabs.addTab( spec );
spec = tabs.newTabSpec( "freeHuntTab" )
           .setContent( R.id.freeHuntTab )
           .setIndicator( getString( R.string.free_hunting_button ), getResources().getDrawable( R.drawable.ic_my_own ) );
tabsDef.put( "freeHuntTab", R.id.freeHuntTab );
tabs.addTab( spec );

我错过了什么?

蒂亚

TabHost tabHost = getTabHost();
TabSpec photospec = tabHost.newTabSpec("Photos");
photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.photos_gray));
Intent photosIntent = new Intent(this,Photosactivity.class);
photospec.setContent(photosIntent);

这是工作...但是图标和文本不是平行显示的,任何一个都可以查看文本或图标

最新更新