Use of fragment-tabbed activity for Android development

Source: Internet
Author: User

When using ADT, you can choose to create a new project by choosing tabbed Activity.

In a new project, selecting a different tab page displays different content, primarily through the fragment getItem (int position) method in the Sectionspageradapter class.

Tabbed Activity Quick use:

1. If it is 3 tab, create a new three fragment in the project, display the content you want to display

2. Find the Sectionspageradapter class, in the fragment getItem (int position) method, you can use the switch statement to display different position depending on the fragment.

1 @Override2          PublicFragment GetItem (intposition) {3             //GetItem is called-instantiate the fragment for the given page.4             //Return a placeholderfragment (defined as a static inner class5             //below).6             Switch(position) {7              Case0:8                 return Newimg1fragment ();9              Case1:Ten                  One                 return Newimg2fragment (); A              Case2: -      -                 return Newimg3fragment (); the  -             } -             return NULL; -}

You can create a new activity with tabbed.

Use of fragment-tabbed activity for Android development

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.