我正在开发基于android标签的应用程序,我需要知道如何用新标签替换现有的标签项。
萨姆
答案 0 :(得分:1)
要动态删除标签,请尝试...
// data structure, what I referred to as memory
ArrayList<TabHost.TabSpec> list = new ArrayList<TabHost.TabSpec>();
// when you are adding tabs to tab host
// what you add, you remember
TabHost.TabSpec spec = tabs.newTabSpec("tag1");
spec.setContent(R.id.button);
spec.setIndicator("TabONe");
tabs.addTab(spec);
list.add(spec);
...
// when you want to remove
list.remove(list.size()-1); // remove it from memory
//set here current tab position
tabs.clearAllTabs(); // clear all tabs from the tabhost
for(TabHost.TabSpec spec : list) // add all that you remember back
tabs.addTab(spec);
要在同一位置添加另一个,请添加新的TabSpec ..