0

我正在尝试TabHost用's 填充,一切都很好,但没有显示TabSpec插入的图标。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 );

我错过了什么?

TIA

4

1 回答 1

0
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);

这是有效的......但图标和文本没有并行显示,任何一个都可以查看文本或图标

于 2016-08-13T06:04:13.777 回答