【发布时间】:2013-05-16 10:20:01
【问题描述】:
我想在 Image 中创建如下图所示的 Tabview。我试过了,但看不到正确的视图。
这是我的代码.. 它没有给出我想要的确切视图。那么,我该如何定制呢。
public class BandInfo extends TabActivity implements OnTabChangeListener {
TabHost tabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.band_info);
tabHost = getTabHost();
tabHost.getTabWidget().setBackgroundResource(R.drawable.footerbar);
// Tab for Bio
TabSpec bioSpec = tabHost.newTabSpec("Bio");
// Setting Title for Tab
bioSpec.setIndicator("Bio");
Intent bioIntent = new Intent(this,Bio.class);
bioSpec.setContent(bioIntent);
// Tab for Upcoing Shows
TabSpec upcomingShowSpec = tabHost.newTabSpec("Upcoming Shows");
upcomingShowSpec.setIndicator("Upcoming Shows");
Intent upcomingShowIntent = new Intent(this, UpcomingShow.class);
upcomingShowSpec.setContent(upcomingShowIntent);
// Tab for Band Members
TabSpec bandMemberSpec = tabHost.newTabSpec("Band Members");
bandMemberSpec.setIndicator("Band Members");
Intent bandMemberIntent = new Intent(this, BandMembers.class);
bandMemberSpec.setContent(bandMemberIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(bioSpec); // Adding Bio Tab
tabHost.addTab(upcomingShowSpec); // Adding Upcoming Show Tab
tabHost.addTab(bandMemberSpec); // Adding Band Members Tab
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.footerbar);
}
tabHost.getTabWidget().setDividerDrawable(R.drawable.footer_saprater);
}
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.footerbar);
}
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(R.drawable.bandmember_active);
}
请帮我写一些代码... 在此先感谢..
这是我得到的输出屏幕。
【问题讨论】:
-
你做过什么吗?
-
是的,我试了一下,但是标签的标题名称没有设置在中心..
-
嗨...你还是不能解决问题??
-
使用带有背景图片的TextView,而不是使用TabView。
-
请显示您使用此代码获得的图像。以便其他人可以了解您使用此代码获得的结果以及您要实现的目标。
标签: android customization tabview