0
我一直在開發應用程序,用來製作TabHost下面的代碼:如何在TabHost中更改TabSpec的標題/內容?
TabHost.TabSpec spec=mTabHostCategories.newTabSpec("Main");
spec.setIndicator("Main");
spec.setContent(R.id.listViewMain);
mTabHostCategories.addTab(spec);
mTabSpecFirst=mTabHostCategories.newTabSpec("First");
mTabSpecFirst.setContent(R.id.listViewFirst);
mTabSpecFirst.setIndicator(mCategoryFirst);
mTabHostCategories.addTab(mTabSpecFirst);
mTabSpecSecond=mTabHostCategories.newTabSpec("Second");
mTabSpecSecond.setContent(R.id.listViewSecond);
mTabSpecSecond.setIndicator(mCategorySecond);
mTabHostCategories.addTab(mTabSpecSecond);
mTabHostCategories.setCurrentTab(0);
但後來我需要改變標題(指標)和內容TabSpecs。我該怎麼做?謝謝。
mCategoryFirst是簡單的String對象。我該如何改變它? – user1166635
然後只需調用'mTabSpecFirst.SetIndicator(「new title」);'更改第一個標籤的標題 – waqaslam