0
두 개의 탭이있는 TabHost가 있습니다. 사용자가 두 탭 중 하나를 클릭 할 때를 알고 싶습니다. 이것을 어떻게 할 수 있습니까?사용자가 TabHost 내부의 탭을 클릭했는지 확인하는 방법은 무엇입니까?
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, Main.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("watchlist").setIndicator("Watchlist",res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, ARActivity.class);
spec = tabHost.newTabSpec("trending").setIndicator("Trending",res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
질문이 명확하지 않습니다. 사용자가 탭을 클릭하면 탭이 변경되고 새 탭의 활동이 활성화되므로 탭이 클릭되었음을 이미 알 수 있습니다. – Squonk
거기에 몇 가지 물건을 할 수 있도록 탭에 onclick 수신기를 추가하는 방법이 있습니까? –