Java Code Examples for android.support.design.widget.TabLayout

The following are top voted examples for showing how to use android.support.design.widget.TabLayout. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Croprotector   File: Analysis_fragment.java   View source code 9 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState){
    super.onActivityCreated(savedInstanceState);

    mTabLayout=(TabLayout)view.findViewById(R.id.tabs);

    disease_num_chart_fragment Numchart=new disease_num_chart_fragment();
    disease_kind_chart_fragment Kindchart=new disease_kind_chart_fragment();
    disease_chart_fragment chart=new disease_chart_fragment();
    fragmentList.add(Numchart);
    fragmentList.add(Kindchart);
    fragmentList.add(chart);

    //去除阴影
    toolbar=(Toolbar)LayoutInflater.from(getActivity()).inflate(R.layout.activity_main,null).findViewById(R.id.toolBar);
    toolbar.setElevation(0);

    mViewPager=(ViewPager)view.findViewById(R.id.viewPager);
    adapter=new AnalysisAdapter(getChildFragmentManager(),fragmentList);
    mViewPager.setAdapter(adapter);

    mTabLayout.setupWithViewPager(mViewPager);

}
 
Example 2
Project: Instincts-2k17   File: ScheduleActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Schedule");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.getTabAt(1).select();
}
 
Example 3
Project: civify-app   File: IntroductionActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.introduction_view_pager);

    ArrayList<IntroductionFragment> fragments = new ArrayList<>();
    initFragmentList(fragments);

    LinearLayout linearLayout = (LinearLayout) findViewById(R.id
            .introduction_linear_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.introduction_view_pager);

    mPagerAdapter = new IntroductionPagerAdapter(getSupportFragmentManager(), fragments);
    viewPager.setAdapter(mPagerAdapter);

    TabLayout tabLayout = (TabLayout) linearLayout.findViewById(
            R.id.introduction_tab_layout);
    tabLayout.setupWithViewPager(viewPager, true);
}
 
Example 4
Project: TextEmoji   File: MainActivity.java   View source code 6 votes vote down vote up
private void setTabUnSelectedState(TabLayout.Tab tab) {
    View customView = tab.getCustomView();
    TextView tabText = (TextView) customView.findViewById(R.id.tv_tab_text);
    ImageView tabIcon = (ImageView) customView.findViewById(R.id.iv_tab_icon);
    tabText.setTextColor(ContextCompat.getColor(this, R.color.black_1));
    String s = tabText.getText().toString();
    if (getString(R.string.item_home).equals(s)) {
        tabIcon.setImageResource(R.drawable.home);
    } else if (getString(R.string.item_collect).equals(s)) {
        tabIcon.setImageResource(R.drawable.collect);
    } else if (getString(R.string.item_collect).equals(s)) {
        tabIcon.setImageResource(R.drawable.collect);
    } else if (getString(R.string.item_collect).equals(s)) {
        tabIcon.setImageResource(R.drawable.collect);
    }
}
 
Example 5
Project: Plamber-Android   File: LibraryActivity.java   View source code 6 votes vote down vote up
public void setupPager() {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    //adapter.addFragment(new LocalFileFragment(), getString(R.string.local_file_title));
    adapter.addFragment(new UserBookFragment(), getString(R.string.my_books));
    adapter.addFragment(new LibraryFragment(), getString(R.string.library));
    adapter.addFragment(new RecommendedFragmnet(), getString(R.string.recommended));
    adapter.addFragment(new UploadFragment(), getString(R.string.upload));
    mViewPager.setAdapter(adapter);
    mTabLayout.setupWithViewPager(mViewPager);

    if (utils.getWidthDeviceDP() > 400) {
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    } else {
        mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
 
Example 6
Project: javaide   File: ThemeFontActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_theme_font);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setupToolbar();

    FirebaseAnalytics.getInstance(this).logEvent("open_choose_font_theme", new Bundle());

    viewPager = (ViewPager) findViewById(R.id.view_pager);
    adapter = new SectionPageAdapter(getSupportFragmentManager(), this);
    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(3);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 7
Project: pvdisplay   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Fabric.with(this, new Crashlytics());

    Log.i(TAG, "Creating main activity");

    setContentView(R.layout.activity_main);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    TabsAdapter tabsAdapter = new TabsAdapter(getSupportFragmentManager(), MainActivity.this);
    viewPager.setAdapter(tabsAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
 
Example 8
Project: GitHub   File: MainFragment.java   View source code 6 votes vote down vote up
private void initViews(View view) {

        tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
        ViewPager viewPager = (ViewPager) view.findViewById(R.id.view_pager);
        viewPager.setOffscreenPageLimit(3);

        adapter = new MainPagerAdapter(
                getChildFragmentManager(),
                context,
                zhihuDailyFragment,
                guokrFragment,
                doubanMomentFragment);

        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);

    }
 
Example 9
Project: CodeInPython   File: TutorialsActivity.java   View source code 6 votes vote down vote up
@Override
public void run()
{

    if(tabLayout6.getWidth() < TutorialsActivity.this.getResources().getDisplayMetrics().widthPixels)
    {
        tabLayout6.setTabMode(TabLayout.MODE_FIXED);
        ViewGroup.LayoutParams mParams = tabLayout6.getLayoutParams();
        mParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
        tabLayout6.setLayoutParams(mParams);

    }
    else
    {
        tabLayout6.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
 
Example 10
Project: JsoupSample   File: TabFragment.java   View source code 6 votes vote down vote up
@Override
protected void initActivityCreated() {
    switch (type) {
        case ApiConfig.Type.DYTT:
            tabLayout.setTabMode(TabLayout.MODE_FIXED);
            break;
        case ApiConfig.Type.DY_2018:
        case ApiConfig.Type.XIAO_PIAN:
        case ApiConfig.Type.PIAO_HUA:
        case ApiConfig.Type.K_567:
            tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
            break;
    }
    TabAdapter tabAdapter = new TabAdapter(getChildFragmentManager(), type);
    viewPager.setAdapter(tabAdapter);
    tabLayout.setupWithViewPager(viewPager);
    viewPager.setOffscreenPageLimit(tabAdapter.getCount());
}
 
Example 11
Project: ChenYan   File: HomeFragment.java   View source code 6 votes vote down vote up
@Override
public void init() {
    super.init();
    activityFragment = new ActivityFragment();
    articleFragment = new ArticleFragment();

    fragments.add(articleFragment);
    fragments.add(activityFragment);
    titles.add(ARTICLE);
    titles.add(ACTIVITY);

    pageAdapter = new PageAdapter(getChildFragmentManager(), fragments, titles);

    viewPager.setAdapter(pageAdapter);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabMode(TabLayout.MODE_FIXED);

    bgaBanner.setData(R.drawable.banner1, R.drawable.banner2, R.drawable.banner3, R.drawable.banner4);
    bgaBanner.setDelegate(new BGABanner.Delegate() {
        @Override
        public void onBannerItemClick(BGABanner banner, View itemView, Object model, int position) {
            showToast(position + "");
        }
    });
}
 
Example 12
Project: AndroidSkinAnimator   File: MainActivity.java   View source code 6 votes vote down vote up
private void configFragments() {
    List<Fragment> list = new ArrayList<>();
    list.add(new FirstFragment());
    list.add(new MiddleFragment());
    list.add(new LastFragment());
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    viewPager.setAdapter(new TabFragmentPagerAdapter(getSupportFragmentManager(), list));
    List<String> listTitle = new ArrayList<>();
    listTitle.add("系统组件");
    listTitle.add("自定义View");
    listTitle.add("第三方库控件");
    mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
    viewPager.setAdapter(mTabFragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 13
Project: Ency   File: GankMainFragment.java   View source code 6 votes vote down vote up
@Override
    protected void initialize() {
        types.add("Android");
        types.add("IOS");
        types.add("前端");
        types.add("拓展资源");
//        types.add("瞎推荐");
//        types.add("福利");
        fragments.add(GankFragment.newInstance("Android"));
        fragments.add(GankFragment.newInstance("iOS"));
        fragments.add(GankFragment.newInstance("前端"));
        fragments.add(GankFragment.newInstance("拓展资源"));
//        fragments.add(GankFragment.newInstance("瞎推荐"));
//        fragments.add(GankFragment.newInstance("福利"));
        titleAdapter = new TitleAdapter(getChildFragmentManager(), fragments, types);
        viewPager.setAdapter(titleAdapter);
        tablayout.setTabMode(TabLayout.MODE_FIXED);
        tablayout.setupWithViewPager(viewPager);
    }
 
Example 14
Project: TextEmoji   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    initTabList();
    mAdapter = new TabLayoutFragmentAdapter(getSupportFragmentManager(), mTabList, this, mFragments, mTabImgs);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
    mTabLayout.setupWithViewPager(mViewPager);
    mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    for (int i = 0; i < mTabLayout.getTabCount(); i++) {
        mTabLayout.getTabAt(i).setCustomView(mAdapter.getTabView(i));
    }
    mTabLayout.addOnTabSelectedListener(this);
}
 
Example 15
Project: UcMainPagerDemo-master   File: MainActivity.java   View source code 6 votes vote down vote up
protected void initView() {
    findViewById(R.id.iv_github).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openMyGitHub();
        }


    });
    mPagerBehavior = (UcNewsHeaderPagerBehavior) ((CoordinatorLayout.LayoutParams) findViewById(R.id.id_uc_news_header_pager).getLayoutParams()).getBehavior();
    mPagerBehavior.setPagerStateListener(this);
    mNewsPager = (ViewPager) findViewById(R.id.id_uc_news_content);
    mTableLayout = (TabLayout) findViewById(R.id.id_uc_news_tab);
    mFragments = new ArrayList<TestFragment>();
    for (int i = 0; i < 4; i++) {
        mFragments.add(TestFragment.newInstance(String.valueOf(i), false));
        mTableLayout.addTab(mTableLayout.newTab().setText("Tab" + i));
    }
    mTableLayout.setTabMode(TabLayout.MODE_FIXED);
    mTableLayout.setOnTabSelectedListener(this);
    mNewsPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTableLayout));
    mNewsPager.setAdapter(new TestFragmentAdapter(mFragments, getSupportFragmentManager()));
}
 
Example 16
Project: Tribe   File: PersonalHomeActivity.java   View source code 6 votes vote down vote up
/**
 * 初始化ViewPager,在拿到数据后调用
 */
private void initViewPager(UserBeanRepc userBeanRepc){

    PInformationFragment pInformationFragment=new PInformationFragment();
    Bundle bundle = new Bundle();
    bundle.putParcelable("user",userBeanRepc);
    pInformationFragment.setArguments(bundle);

    PDynamicsFragment dynamicsFragment=new PDynamicsFragment();
    PCompanionFragment companionFragment=new PCompanionFragment();
    List<Fragment> vFragLists=new ArrayList<>();
    vFragLists.add(pInformationFragment);
    vFragLists.add(dynamicsFragment);
    vFragLists.add(companionFragment);

    String tabs[]=new String[]{"资料", "动态", "结伴"};

    ViewPagerAdapter vpAdapter = new ViewPagerAdapter(getSupportFragmentManager(),vFragLists,tabs);
    mMainContainer.setAdapter(vpAdapter);
    mMainContainer.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener
            (mToolbartab));
    mMainContainer.setOffscreenPageLimit(2);
    mToolbartab.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mMainContainer));
    reflex(mToolbartab);
}
 
Example 17
Project: wisebite_android   File: MainActivity.java   View source code 6 votes vote down vote up
/**
 * Initialize analytics fragment
 */
private void initializeAnalytics() {
    setTitle(getResources().getString(R.string.analytics));
    removeTabs();
    if (this.menu != null) this.menu.findItem(R.id.action_change_day).setVisible(true);
    fab.setVisibility(View.GONE);

    tabs = new TabLayout(MainActivity.this);
    tabs.setTabTextColors(Color.parseColor("#FFFFFF"), Color.parseColor("#FFFFFF"));
    appBar.addView(tabs);

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
    adapter.addFragment(new AnalyticsDayFragment(MainActivity.this, restaurantId), getString(R.string.per_day));
    adapter.addFragment(new AnalyticsWeekFragment(MainActivity.this, restaurantId), getString(R.string.per_week));
    adapter.addFragment(new AnalyticsMonthFragment(MainActivity.this, restaurantId), getString(R.string.per_month));
    viewPager.setAdapter(adapter);
    tabs.setupWithViewPager(viewPager);
}
 
Example 18
Project: CodeMania   File: SearchUser.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_user);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);


    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
}
 
Example 19
Project: RantApp   File: NotifyFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_notify, container, false);
    setRetainInstance(true);

    mToolbar = (Toolbar) view.findViewById(R.id.fragment_notify_toolbar);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    activity.getSupportActionBar().setDisplayShowTitleEnabled(false);


    mTabLayout = (TabLayout) view.findViewById(R.id.fragment_notify_tab_layout);
    mViewPager = (ViewPager) view.findViewById(R.id.fragment_notify_view_pager);

    mViewPager.setAdapter(new MyPagerAdapter(getChildFragmentManager()));

    mViewPager.setOffscreenPageLimit(2);

    mTabLayout.setupWithViewPager(mViewPager);

    return view;
}
 
Example 20
Project: ifcalc   File: CalculatorActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calculator);

    setUpToolbar(getString(R.string.title_activity_calculator));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSectionsPagerAdapter = new CalculatorAdapter(getSupportFragmentManager(), getApplicationContext());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    closeKeyboard();

}
 
Example 21
Project: AddressChecker   File: AddressCheckActivity.java   View source code 6 votes vote down vote up
@Override
public void onTabSelected(TabLayout.Tab tab) {
    int newPosition = tab.getPosition();
    switch (newPosition) {
        case 1: {
            if (mTwoList == null) {
                mTabLayout.getTabAt(mCurrentPosition).select();
                return;
            }
            break;
        }
        case 2: {
            if (mThreeList == null) {
                mTabLayout.getTabAt(mCurrentPosition).select();
                return;
            }
            break;
        }
    }
    this.mCurrentPosition = tab.getPosition();
}
 
Example 22
Project: cat-is-a-dog   File: HabitSummaryActivity.java   View source code 6 votes vote down vote up
/**
 * Set up tab layout
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_habit_summary);
    drawToolbar();

    ViewPager viewPager = (ViewPager) findViewById(R.id.habitSummaryPager);
    adapter = new ViewPagerAdapter(getSupportFragmentManager());

    adapter.addFragment(new MyHabitsFragment(), "My Habits");
    adapter.addFragment(new TodoHabitsFragment(), "Todo");
    adapter.addFragment(new FollowingHabitsFragment(), "Following");
    viewPager.setAdapter(adapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.habitSummaryTabs);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 23
Project: order-by-android   File: DownloadHorario.java   View source code 5 votes vote down vote up
public DownloadHorario(Context c, FragmentManager m, int turma, ViewPager v, TabLayout t, RelativeLayout r)
{
    mContext = c;
    mTurma = turma;
    mViewPager = v;
    mFragmentManager = m;
    mTabLayout = t;
    mRelativeLayout = r;
}
 
Example 24
Project: Nimbus   File: ProfileActivity.java   View source code 5 votes vote down vote up
private void findViews(){

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        tabLayout = (TabLayout) findViewById(R.id.tablayout);
        viewPager = (ViewPager) findViewById(R.id.viewpager);
        collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapse_toolbar);
        coverImage = (ImageView) findViewById(R.id.cover);
        profilePic = (ImageView) findViewById(R.id.profilePic);

    }
 
Example 25
Project: JYShare   File: MainActivity.java   View source code 5 votes vote down vote up
private void initView()
{
	mToolbar = (Toolbar) findViewById(R.id.activity_toolbar);
	mTabLayout = (TabLayout) findViewById(R.id.tl_main_tabs);
	mViewPager = (ViewPager) findViewById(R.id.vp_main_content);
	initToolBar();
	initMainContent();
}
 
Example 26
Project: badgedtablayout   File: BadgedTabLayout.java   View source code 5 votes vote down vote up
/**
 * Invalidates the tab views
 */
public void updateTabViews() {
    for (int i = 0; i < getTabCount(); i++) {
        TabLayout.Tab tab = getTabAt(i);
        if (tab != null)
            tab.setCustomView(makeCustomView(tab, R.layout.badged_tab));
    }
}
 
Example 27
Project: revolution-irc   File: ChatFragment.java   View source code 5 votes vote down vote up
@Override
public void onUnreadMessageCountChanged(ServerConnectionInfo info, String channel,
                                        int messageCount, int oldMessageCount) {
    if (messageCount == 0 || (messageCount > 0 && oldMessageCount == 0)) {
        getActivity().runOnUiThread(() -> {
            int tabNumber = mSectionsPagerAdapter.findChannel(channel);
            TabLayout.Tab tab = mTabLayout.getTabAt(tabNumber);
            if (tab != null)
                updateTabLayoutTab(tab);
        });
    }
}
 
Example 28
Project: UCMainViewForBehavior   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.uc_main_view_layout);
    mTabLayout = (TabLayout) findViewById(R.id.news_view_tab_layout);
    mViewPager = (ViewPager) findViewById(R.id.news_view_content_layout);

    mUCViewHeaderBehavior = (UCViewHeaderBehavior) ((CoordinatorLayout.LayoutParams)findViewById(R.id.news_view_header_layout).getLayoutParams()).getBehavior();
    initViewData();
}
 
Example 29
Project: nativead   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	setSupportActionBar(toolbar);
	
	mViewpager = (ViewPager) findViewById(R.id.viewpager);
	mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
	
	mAdBannerFragment = new AdBannerFragment();
	mAdLargeFragment = new AdLargeFragment();
	mAdRectangleFragment = new AdRectangleFragment();
	mAdInfoFlowFragment = new AdInfoFlowFragment();
	ArrayList<BasePagerAdapter.FragmentModel> mLists = new ArrayList<>();
	mLists.add(new BasePagerAdapter.FragmentModel("信息流", mAdInfoFlowFragment));
	mLists.add(new BasePagerAdapter.FragmentModel("大图", mAdLargeFragment));
	mLists.add(new BasePagerAdapter.FragmentModel("方图", mAdRectangleFragment));
	mLists.add(new BasePagerAdapter.FragmentModel("横幅", mAdBannerFragment));
	
	mViewPagerAdapter = new BasePagerAdapter(getSupportFragmentManager(), mLists);
	mViewpager.setAdapter(mViewPagerAdapter);
	mViewpager.setCurrentItem(0);
	mTabLayout.setupWithViewPager(mViewpager);
	
	// 添加一个广告下载监听器
	mMyOnYoumiNativeAdDownloadListener = new MyOnYoumiNativeAdDownloadListener(this);
	YoumiNativeAdHelper.addOnYoumiNativeAdDownloadListener(mMyOnYoumiNativeAdDownloadListener);
}
 
Example 30
Project: MVPArms_Fragment-fragment   File: AutoTabLayout.java   View source code 5 votes vote down vote up
public AutoTabLayout(Context context, AttributeSet attrs, int defStyleAttr)
{
    super(context, attrs, defStyleAttr);

    initTextSizeBaseWidth(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout,
            defStyleAttr, R.style.Widget_Design_TabLayout);
    int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance,
            R.style.TextAppearance_Design_Tab);

    mTextSize = loadTextSizeFromTextAppearance(tabTextAppearance);
    a.recycle();
}
 
Example 31
Project: TPlayer   File: OtherUserHomeActivity.java   View source code 5 votes vote down vote up
private void initView() {
    layout_appbar = (AppBarLayout) findViewById(R.id.layout_appbar);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    mNick = (TextView) findViewById(R.id.tv_nick);
    iv_logo_head = (ImageView) findViewById(R.id.iv_logo_head);
    tv_logo_nick = (TextView) findViewById(R.id.tv_logo_nick);
    view_divider = findViewById(R.id.view_divider);
    mTabLayout = (TabLayout) findViewById(R.id.layout_tab);
    view_pager = (ViewPager) findViewById(R.id.view_pager);

    toolbar.setTitle("");
    toolbar.setSubtitle("");
    toolbar.setNavigationIcon(R.mipmap.btn_back_normal);
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    layout_appbar.addOnOffsetChangedListener(mOffsetChangerListener);

    tv_logo_nick.setText("Limitless");
    iv_logo_head.setImageResource(R.mipmap.ic_launcher);

    mOffsetChangerListener.resetRange();

    requestData();
}
 
Example 32
Project: XERUNG   File: GroupView.java   View source code 5 votes vote down vote up
private void findViewIds() {
    mLayback = (RelativeLayout) findViewById(R.id.layBack);
    mTxtGroupName = (TextView) findViewById(R.id.txtGroupName);
    mTxtGroupName.setTypeface(ManagerTypeface.getTypeface(GroupView.this, R.string.typeface_android));
    mTxtGroupDesc = (TextView) findViewById(R.id.txtGroupdesc);
    mTxtGroupDesc.setTypeface(ManagerTypeface.getTypeface(GroupView.this, R.string.typeface_roboto_regular));
    mTxtGrouptag = (TextView) findViewById(R.id.txtGroupTag);
    mTxtGrouptag.setTypeface(ManagerTypeface.getTypeface(GroupView.this, R.string.typeface_roboto_regular));
    layedit = (DiagonalLayout) findViewById(R.id.diagonalLayout);
    imgAdd = (ImageView) findViewById(R.id.txtAddMemberGroup);
    imgSearch = (ImageView) findViewById(R.id.imgSearchMember);
    ivPhoto = (ImageView) findViewById(R.id.imgProfilePicSet);
    tabLayout = (TabLayout) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pagerfilter);
    mTxtPending = (TextView) findViewById(R.id.txtPendingRequest);
    // init view pager
    pagerAdapter = new FilterTabsAdapter(getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    tabLayout.setupWithViewPager(pager);
    setTabIcons();
    try {
        tabLayout.getTabAt(0).getCustomView().setSelected(true);
    } catch (Exception e) {
        // Add default picture
        e.printStackTrace();
    }
}
 
Example 33
Project: Protein   File: MainView.java   View source code 5 votes vote down vote up
@Override
public void setupView() {
    RxView.clicks(userLayout)
            .throttleFirst(RxUtils.WINDOW_DURATION, RxUtils.TIME_UNIT)
            .subscribe(o -> presenter.onToolbarUserClicked());

    toolbar.inflateMenu(R.menu.main_menu);
    toolbar.getMenu().findItem(R.id.action_logout).setEnabled(AccountManager.getInstance().isLogin());
    toolbar.setOnMenuItemClickListener(item -> {
        if (item.getItemId() == R.id.action_about) {
            presenter.toAbout();
            return true;
        } else if (item.getItemId() == R.id.action_logout) {
            presenter.showLogoutDialog();
            return true;
        }
        return false;
    });

    viewPager.setAdapter(new MainPagerAdapter(((FragmentActivity) getContext()).getSupportFragmentManager()));

    // Add 4 tabs for TabLayout
    tabLayout.addTab(tabLayout.newTab().setText(R.string.home_tab_popular)); // Popular
    if (AccountManager.getInstance().isLogin()) {
        tabLayout.addTab(tabLayout.newTab().setText(R.string.home_tab_following)); // Following
    }
    tabLayout.addTab(tabLayout.newTab().setText(R.string.home_tab_recent)); // Recent
    tabLayout.addTab(tabLayout.newTab().setText(R.string.home_tab_debuts)); // Debuts

    // Setup sync between TabLayout and ViewPager
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));
    viewPager.setOffscreenPageLimit(3);
}
 
Example 34
Project: hubISM   File: jodnewala.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View viewa=inflater.inflate(R.layout.fragment_jodnewala, container, false);
    viewPager = (ViewPager) viewa.findViewById(R.id.viewpager);

    setupViewPager(viewPager);

    tabLayout = (TabLayout) viewa.findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    return viewa;
}
 
Example 35
Project: Aurora   File: AutoTabLayout.java   View source code 5 votes vote down vote up
public AutoTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    initTextSizeBaseWidth(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout,
            defStyleAttr, R.style.Widget_Design_TabLayout);
    int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance,
            R.style.TextAppearance_Design_Tab);

    mTextSize = loadTextSizeFromTextAppearance(tabTextAppearance);
    a.recycle();
}
 
Example 36
Project: order-by-android   File: FaltasFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final View myFragmentView = inflater.inflate(R.layout.fragment_faltas, container, false);

    //Obtem da View
    mViewPager = (ViewPager) myFragmentView.findViewById(R.id.vp_tab);
    //Obtem da View
    mRelativeLayout = (RelativeLayout) myFragmentView.findViewById(R.id.pb_falta);

    //Obtem da View
    mTabLayout = (TabLayout) myFragmentView.findViewById(R.id.tl_faltas);

    //Verifica se há erros
    if(erro)
    {
        //Mostra a mensagem de erro
        mRelativeLayout.findViewById(R.id.tv_erro).setVisibility(View.VISIBLE);
        mRelativeLayout.findViewById(R.id.pb_falta_indeterminate).setVisibility(View.GONE);
    }
    //Verifica se há faltas
    else if(mFaltas==null)
        //Baixa as faltas
        new DownloadFaltas(getActivity(),getFragmentManager(),ActivityPrincipal.mAluno.getRm(),mViewPager,mTabLayout,mRelativeLayout).execute(Utils.getUrlApiFalta(getActivity()));
    else {
        //Configura e mostra as faltas já obtidas
        setupViewPager(mViewPager, mTabLayout);
        mRelativeLayout.setVisibility(View.GONE);
        mTabLayout.setVisibility(View.VISIBLE);
        mViewPager.setVisibility(View.VISIBLE);
    }

    return myFragmentView;
}
 
Example 37
Project: Search-em-All   File: ViewPagerFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.viewpager_fragment, container, false);
    // TODO : replace this with fetched urls
    mUtil = new Util(getContext());
    mProperties = readAssets(getAssetName());
    mArrayListSize = mProperties.size();
    mTabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
    initViewPager(view);
    mTabLayout.setupWithViewPager(mViewPager);
    return view;
}
 
Example 38
Project: OSchina_resources_android   File: TweetDetailViewPagerFragment.java   View source code 5 votes vote down vote up
@Override
public void onLikeSuccess(boolean isUp, User user) {
    mOperator.getTweetDetail().setLikeCount(mOperator.getTweetDetail().getLikeCount() + (isUp ? 1 : -1));
    if (mThumbupViewImp != null) mThumbupViewImp.onLikeSuccess(isUp, user);
    TabLayout.Tab tab = mTabLayout.getTabAt(0);
    if (tab != null)
        tab.setText(String.format("赞(%s)", mOperator.getTweetDetail().getLikeCount()));
}
 
Example 39
Project: CommonsLab   File: MainActivity.java   View source code 5 votes vote down vote up
private void initViewPagerAndTabs() {
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    pagerAdapter = new TabbedPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    tabLayout.setupWithViewPager(viewPager);
    customizeTabFont();
}
 
Example 40
Project: Selector   File: ProductDetailActivity.java   View source code 5 votes vote down vote up
private void setPriceSortDrawable(int priceSortMode, TabLayout.Tab tab) {
  View view = tab.getCustomView();
  img_title = (ImageView) view.findViewById(R.id.title_iv);
  switch (priceSortMode) {
    case 0:
      img_title.setImageResource(R.drawable.search_icon_price_normal);
      break;
    case 1:
      img_title.setImageResource(R.drawable.search_icon_price_down);
      break;
    case 2:
      img_title.setImageResource(R.drawable.search_icon_price_up);
      break;
  }
}