2011-03-31 2 views

답변

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

+0

이 나를 위해 일하지만, 때 .. 새을 TabSpec을 추가하는 것과 동일한 위치에 다른하여이를 추가하려면 탭 변경 탭이 왼쪽에서 오른쪽으로 이동하면 삼성 넥서스 S 휴대 전화를 확인하고 있습니다 ... – Sam

+0

안녕하세요. 위의 예에서 마지막 탭을 제거했습니다. 사이에있는 탭을 제거하고 해당 위치에 새 탭을 추가 할 수도 있습니다. list.remove (2); list.set (2, spec); 다음 추가 탭에 대한 foreach 루프를 적용하십시오. –

관련 문제