# PagerAdapter 主要方便TabLayout和ViewPager进行结合使用 ### 具体使用(案例) 代码 xml布局 ```xml ``` 绑定ViewPager activity或者fragment里进行设置 ```kotlin //Fragment集合 private val mPageList = arrayListOf( FlowFragment(), ShapeFragment(), SearchFragment(), ActionBarFragment(), KeyboardFragment() ) //标题集合 和Fragment保持一致 private val mPageTitle = arrayListOf("流式布局", "Shape背景", "自定义搜索框", "标题栏", "数字键盘") override fun initData() { val fragmentPagerAdapter = FragmentPagerAdapter(mPageList, mPageTitle) mBinding.vpView.adapter = fragmentPagerAdapter mBinding.tabLayout.setupWithViewPager(mBinding.vpView) } ``` 效果 ## License ``` Copyright (C) AbnerMing, VipBase Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```