读书人

动态更替tab indicator

发布时间: 2012-09-21 15:47:26 作者: rapoo

动态更换tab indicator

初始化

tabHost = getTabHost(); ?
TabSpec tabSpec = tabHost.newTabSpec("abc");?
tabSpec.setIndicator("helloabc");?
tabSpec.setContent(new MyViewFactory());?
tabHost.addTab(tabSpec);?

我想动态更换为

TabSpec tabSpec = MyTabActivity.getTabSpec();?
tabSpec.setIndicator("xyz");?
可是上面的方法不好用

要想修改需要用:

TextView title = (TextView) tabHost.getTabWidget().getChildAt(tabId).findViewById(android.R.id.title)?
title.setText("xyz");?

读书人网 >移动开发

热点推荐