Reputation: 6922
I use tabhost in my app. I use below code to add intent:
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
Resources res = getResources();
intent = new Intent().setClass(this, AActivity.class);
spec = tabHost.newTabSpec("Files").setIndicator("NAS Files", res.getDrawable(R.drawable.ic)).setContent(intent);
tabHost.addTab(spec);
In AActivity, I want to hide the tabs(TabWidget) while the button was clicked. And click two times to show tabs. How can I do it?
Upvotes: 2
Views: 9795
Reputation: 1371
There are three states for view visibility in Android.
Below are how you do so programatically.
tabhost.setVisibility( View.VISIBLE );
tabhost.setVisibility( View.INVISIBLE );
tabhost.setVisibility( View.GONE );
So, you can set an OnClickListener
on tabHost
that modifies the visibility of the view.
private OnClickListener tabClickListener = new OnClickListener() {
public void onClick(View v) {
v.setVisibility( View.INVISIBLE );
}
};
// Somewhere else in your code...
tabhost.setOnClickListener( tabClickListener );
To catch double taps, you can keep a counter of taps on the onClick and expire them after a time threshold.
See this question for more info on the double tap
Read the visibility api doc here
Upvotes: 7