动态更换tab indicator

阅读 44

2023-06-21


初始化

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");

精彩评论(0)

0 0 举报