即时通讯新的与Android。android标签图标不显示
现在我试图让工作选项卡布局。我已经完成了一切,就像在Android TabView教程中,应用程序运行正常,但问题是我没有看到任何图标,我已经在ic_tab_artists.xml中定义它们。只有文字。
我想它与默认的主题是什么或风格或什么。我试图改变它,但它根本没有帮助,只是一个文本。
我正在使用Android SDK v4.03。
我确定有足够的Android大师会提供帮助,所以在此先感谢。
这是我的.xml定义使用图标:
?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_artists_grey"
android:state_selected="true" />
<!-- When not selected (default), use white-->
<item android:drawable="@drawable/ic_tab_artists_white" />
</selector>
而我的主要HolePage活动:
@SuppressWarnings("deprecation")
public class HolePage extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hole_page);
//TABS
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, HolePageScores.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("scores").setIndicator("Scores",
res.getDrawable(R.drawable.tab_scores_icons))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs - Info
intent = new Intent().setClass(this, HolePageInfo.class);
spec = tabHost.newTabSpec("info").setIndicator("Info",
res.getDrawable(R.drawable.tab_scores_icons))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs - Top
intent = new Intent().setClass(this, HolePageTop.class);
spec = tabHost.newTabSpec("top").setIndicator("Top",
res.getDrawable(R.drawable.tab_scores_icons))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs - Hole
intent = new Intent().setClass(this, HolePageHole.class);
spec = tabHost.newTabSpec("hole").setIndicator("Hole",
res.getDrawable(R.drawable.tab_scores_icons))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs - Par
intent = new Intent().setClass(this, HolePagePar.class);
spec = tabHost.newTabSpec("par").setIndicator("Par",
res.getDrawable(R.drawable.tab_scores_icons))
.setContent(intent);
tabHost.addTab(spec);
//Set default tab2
tabHost.setCurrentTab(1);
}
}
你可以发布你的代码吗?你可以通过代码设置你的图标..你做到了吗? – Hiral 2012-02-10 09:59:02
当然,如果你的意思是.xml,它定义了要加载哪些图标以及何时> – 2012-02-10 10:01:11
,请编辑你的问题并在其中放置代码! – Hiral 2012-02-10 10:04:30