找传奇、传世资源到传世资源站!

TabLayout、ViewPager、NavigationView 实现的tab签

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

TabLayoutViewPager、NavigationView
from clipboardfrom clipboard
package com.example.carson_ho.toptabbar;import android.os.Bundle;import android.support.design.widget.TabLayout;import android.support.v4.view.ViewPager;import android.support.v7.app.AppCompatActivity;public class MainActivity extends AppCompatActivity { private TabLayout mTabLayout; private ViewPager mViewPager; private MyFragmentPagerAdapter myFragmentPagerAdapter; private TabLayout.Tab one; private TabLayout.Tab two; private TabLayout.Tab three; private TabLayout.Tab four; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_main); //初始化视图 initViews(); } private void initViews() { mViewPager= (ViewPager) findViewById(R.id.viewPager); myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(myFragmentPagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.tabLayout); mTabLayout.setupWithViewPager(mViewPager); one = mTabLayout.getTabAt(0); two = mTabLayout.getTabAt(1); three = mTabLayout.getTabAt(2); four = mTabLayout.getTabAt(3); one.setIcon(R.mipmap.ic_launcher); two.setIcon(R.mipmap.ic_launcher); three.setIcon(R.mipmap.ic_launcher); four.setIcon(R.mipmap.ic_launcher); }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复