【发布时间】:2019-08-16 09:26:59
【问题描述】:
我有一个使用 TabActivity 的应用程序,但它在 ICS 上呈现不正确。对 ActionBar 或 Fragments 作为解决方案并不真正感兴趣,因为这些选项卡仍然适用于我和其他应用程序。
这是它在 ICS 上的样子,不正确。
这是我的 tabactivity 选项卡代码,需要更改什么?
intent = new Intent().setClass(this, HomeMenuGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("homeMenuGroup").setIndicator(li.inflate(R.layout.main_tabs_home, tabHost.getTabContentView(), false))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, BuyTicketsGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("buyTicketsGroup").setIndicator(li.inflate(R.layout.main_tabs_buy, tabHost.getTabContentView(), false))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, UseTicketsGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("useTicketsGroup").setIndicator(li.inflate(R.layout.main_tabs_use, tabHost.getTabContentView(), false))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, MyAccountGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("myAccountGroup").setIndicator(li.inflate(R.layout.main_tabs_account, tabHost.getTabContentView(), false))
.setContent(intent);
tabHost.addTab(spec);
这是我的标签按钮布局之一 xml R.layout.main_tabs_account
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:background="@drawable/switcher_account"
android:layout_width="80dip"
android:layout_height="60dip"/>
</LinearLayout>
【问题讨论】:
标签: android tabs android-4.0-ice-cream-sandwich tabactivity