Skip to content

Instantly share code, notes, and snippets.

@Singhak
Created June 21, 2016 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Singhak/9ae19f70b5601b24eaeee43679dcaa53 to your computer and use it in GitHub Desktop.
Save Singhak/9ae19f70b5601b24eaeee43679dcaa53 to your computer and use it in GitHub Desktop.
In this fragment FragmentTabHost is use to show tabs
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTabHost;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
public class TabHostFragment extends Fragment {
FragmentTabHost tabHost;
public TabHostFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_tab_host, container, false);
tabHost = (FragmentTabHost) view.findViewById(android.R.id.tabhost);
tabHost.setup(this.getActivity(), this.getChildFragmentManager(), R.id.content);
tabHost.addTab(tabHost.newTabSpec("one").setIndicator("One"), FragmentA.class, null);
tabHost.addTab(tabHost.newTabSpec("two").setIndicator("Two"), FragmentB.class, null);
return view;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment