Created
June 21, 2016 05:07
-
-
Save Singhak/9ae19f70b5601b24eaeee43679dcaa53 to your computer and use it in GitHub Desktop.
In this fragment FragmentTabHost is use to show tabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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