2016-06-29 4 views
-1

I 탭 호스트에 3 탭이, 나는 Button1을 클릭이 #, 난 전환 그것을 할 때 내가 TAB1, 현재 해요어떻게 탭 호스트의 다른 탭으로 전환 하시겠습니까?

TabSpec Tab1 = tabhost.newTabSpec("Tab1"); 
    jadwalUser.setIndicator("Tab1", getResources().getDrawable(R.drawable.style1)); 
    Intent in1 = new Intent(this, Tab1.class); 
    Tab1.setContent(in1); 

TabSpec Tab2 = tabhost.newTabSpec("Tab2"); 
Tab2.setIndicator("Tab2", getResources().getDrawable(R.drawable.style2)); 
Intent in2 = new Intent(this, Tab2.class); 
Tab2.setContent(in2); 

TabSpec Tab3 = tabhost.newTabSpec("Tab3"); 
Tab3.setIndicator("Tab3", getResources().getDrawable(R.drawable.style3)); 
Intent in3 = new Intent(this, Tab3.class); 
Tab3.setContent(in3); 

tabhost.addTab(Tab1); 
tabhost.addTab(Tab2); 
tabhost.addTab(Tab3);` 

button..` 클릭에 의해 의도로 다른 탭으로 전환합니다 TAB2에 :

button1.setOnClickListener(new OnClickListener() { 

public void onClick(View v) { 
//What code here to switch to Tab2 

} 
} 

이 제발 도와주세요, 감사합니다 ..

+0

활동 또는 조각 사이를 전환 할 것인지 여부 탭에 포함 된 내용은 무엇입니까? – PN10

+0

b/w fragment.Nothing now –

답변

0

당신은 tabTag 당신이을 TabSpec을 만드는 데 사용 된 동일한 문자열 TabHost.setCurrentTabByTag (tabTag)를 호출 할 수 있습니다. 따라서 tab2로 이동하는 예제에서 다음과 같이 문의하십시오 :

tabhost.setCurrentTabByTag("Tab2");