Reputation: 396
i wanna change the current activated Tab of a TabHost.
There were some answers here on SOF, but they dont work, since they all use setCurrentTab.
I have a Map with marker and if i click on one, this function gets called:
public void onMarkerClick(Marker marker) {
findViewById(R.id.createNewMarker).setVisibility(View.GONE);
findViewById(R.id.tab_host).setVisibility(View.VISIBLE);
}
The change of the Visibility works flawless, but when i tried to add findViewById(R.id.tab_host).setCurrentTab(1)
the Method seem to not exists.
What is the currect way to do it?
Upvotes: 0
Views: 29
Reputation: 10881
findViewById(R.id.tab_host)
returns a View
class. TabHost
is a subclass of View
. To use TabHost
methods on object, which is stored as View
, but is a TabHost
in fact, you have to cast it to TabHost
:
((TabHost)findViewById(R.id.tab_host)).setCurrentTab(1)
Upvotes: 1