


1. Add the android support package
Because several classes are provided in the android support package, we first add the android-support-v4.jar file to the libs of the project Just go to the directory.
2. activity_main.xml
android:layout_height="match_parent"
android:orientation="vertical" > ;
xml uses PagerTabStrip as a sub-tag of ViewPager and cannot be taken out, otherwise an error will still be reported
3. In the PagerTabStrip tag, you can use the attribute android:layout_gravity=TOP|BOTTOM to specify the position of the title
4. If To display the title of a page in PagerTabStrip, you need to implement getPageTitle(int)
in the ViewPager adapter -->
use using id ‐ ‐ ‐ ‐ ‐ ‐ ‐ android: t ;
android:layout_height="wrap_content "
android: -
android:layout_gravity = "Bottom"
Android: Visibility = "Gone"/& GT; elayout & gt ;
There are two controls, PagerTitleStrip and PagerTabStrip, which must be used as sub-controls of ViewPager, otherwise an error will be reported.
What is the difference between the two controls?
The simple understanding is:
PagerTabStrip: interactive
PagerTitleStrip: non-interactive
After a simple test, it was found:
PagerTabStrip :
① Click the title above to switch ViewPager.
③ Display full-width underline (setDrawFullUnderline)
PagerTitleStrip:
① Clicking on the title above does not respond.
② No above description.
3. Set the title value
PagerAdater has a getPageTitle, which needs to be rewritten, and then different titles can be returned according to different pages
private class MyPagerAdapter extends PagerAdapter {
@Override
public int getCount() {
return mImageListView.size();
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
container.addView(mImageListView.get(position));
return mImageListView.get(position);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView(mImageListView.get(position));
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "页面0";
case 1:
return "页面1";
case 2:
return "页面2";
case 3:
return "页面3";
}
return super.getPageTitle(position);
}
}
效果如下:

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment
