Demonstrate ViewPager and viewpager
Content
- Environment
- Project Structure
- Demonstration 1: PagerTitleStrip
- Demonstration 2: PagerTabStrip
- Demonstration 3: ViewPager and dynamic Fragment
Download Demo Environment
- Windows 2008 R2 64-bit
- Eclipse ADT V22.6.2, Android 4.4.2 (API 19)
- SAMSUNG GT-8618, Android OS 4.1.2
Project Structure
Figure 1 Project Structure
Figure 2 main project Interface
Demonstration 1: PagerTitleStrip
Figure 3 shows PagerTitleStrip and click "Weibo"
Demonstration 2: PagerTabStrip
Figure 4 PagerTabStrip
In the official document, PagerTabStrip and PagerTitleStrip are described as "PagerTabStrip is an interactive indicator of the current, next, and previous pages ofViewPager. "And" PagerTitleStrip is a non-interactive indicator of the current, next, and previous pages ofViewPager."
To put it simply, PagerTabStrip and PagerTitleStrip can both implement slide switching to the Tab page, but PagerTabStrip also implements switching to the Tab page by clicking the Tab, while PagerTitleStrip cannot.
Demonstration 3: ViewPager and dynamic Fragment
Figure 5 ViewPager and dynamic Fragment
The difference between FragmentStatePagerAdapter and FragmentPagerAdapter is that FragmentStatePagerAdapter only exists in the previous Fragment, and other Fragment will be destroyed, which is suitable for loading multiple data. FragmentPagerAdapter is applicable to all Fragment, therefore, it is not suitable for loading a large number of data slices or something, and it is easy to cause memory overflow.
Download Demo