• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to display fragment in sections

Hi,

I created a template using the AndroidStudio. The app template I choosed to have an action bar. It created 3 sections with one fragment_main

here is the code was created:

[HIGH]public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
// TextView textView = (TextView) rootView.findViewById(R.id.section_label);
// textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
[/HIGH]

I want to know how can I display different layout for every sections so home_section (0) will display fragment_main and contact_section (1) will show the fragment_contact?


Thanks,
Jassim
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones