Does someone know how to use PagerTitleStrip in Android

前端 未结 3 1331
我在风中等你
我在风中等你 2021-02-04 01:33

I decided to use a ViewPager in my application and everything is working fine. I Know that I want to use a PagerTitleStrip in my ViewPager

3条回答
  •  旧时难觅i
    2021-02-04 02:18

    PagerTitleStrip is a non-interactive signal of the current, next, and former pages of a ViewPager. It really is designed to be used as a child view of a ViewPager widget

    Step 1. Create layout activity_main.xml

    
        
        
            
        
         
    

    Step 2. Create Activity contains ViewPager this (MainActvity.java)

    public class MainActivity extends Activity {
     ViewPager viewPager;
     MyPagerAdapter myPagerAdapter;
     @Override
     protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      viewPager = (ViewPager)findViewById(R.id.myviewpager);
      myPagerAdapter = new MyPagerAdapter();
      viewPager.setAdapter(myPagerAdapter);
      PagerTitleStrip pagerTitleStrip = (PagerTitleStrip)findViewById(R.id.titlestrip);
     }
    }
    

    Demo : http://photo-wonder.blogspot.com/2016/09/pagertitlestrip-on-viewpager-android.html

提交回复
热议问题