我有一個使用TabActivity的應用程序,但它在ICS上呈現不正確。對ActionBar或Fragments作爲解決方案沒有真正的興趣,因爲選項卡仍然適用於我和其他應用程序。顯示Tabactivity選項卡的Android ICS錯誤
下面是它看起來像Android上的所有其他版本(所期望的樣子) http://i44.tinypic.com/fb9jya.png
,這裏是什麼樣子的ICS,不正確的。
http://i44.tinypic.com/35btjl2.png
這裏是我的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>
感謝您指出'main_tabs_content'。它是一個具有可繪製背景的文本視圖,具有狀態。我將看到刪除linearlayout並將textview更改爲imageview – CQM 2012-01-05 22:27:06
的工作方式。感謝您的回覆,我只是在閱讀您的建議以及我想象中的錯誤。在其他2.x設備上測試,以確保我保持兼容性 – CQM 2012-01-05 22:42:39