Search in sources :

Example 46 with TabLayout

use of android.support.design.widget.TabLayout in project FastDev4Android by jiangqqlmj.

the class TabInfoFragment method initValidata.

private void initValidata() {
    fragments = new ArrayList<>();
    for (int i = 0; i < 12; i++) {
        OneFragment oneFragment = new OneFragment();
        Bundle bundle = new Bundle();
        bundle.putString("extra", titles[i]);
        oneFragment.setArguments(bundle);
        fragments.add(oneFragment);
    }
    //创建Fragment的 ViewPager 自定义适配器
    mPagerAdater = new CNKFixedPagerAdapter(getChildFragmentManager());
    //设置显示的标题
    mPagerAdater.setTitles(titles);
    //设置需要进行滑动的页面Fragment
    mPagerAdater.setFragments(fragments);
    info_viewpager.setAdapter(mPagerAdater);
    tab_layout.setupWithViewPager(info_viewpager);
    //设置Tablayout
    //设置TabLayout模式 -该使用Tab数量比较多的情况
    tab_layout.setTabMode(TabLayout.MODE_SCROLLABLE);
    //设置自定义Tab--加入图标的demo
    for (int i = 0; i < 12; i++) {
        TabLayout.Tab tab = tab_layout.getTabAt(i);
        tab.setCustomView(mPagerAdater.getTabView(i));
    }
}
Also used : CNKFixedPagerAdapter(com.chinaztt.fda.adapter.CNKFixedPagerAdapter) Bundle(android.os.Bundle) TabLayout(android.support.design.widget.TabLayout)

Example 47 with TabLayout

use of android.support.design.widget.TabLayout in project SearchView by lapism.

the class BaseActivity method setViewPager.

protected void setViewPager() {
    FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
    adapter.addFragment(new SearchFragment(), getString(R.string.installed));
    adapter.addFragment(new SearchFragment(), getString(R.string.all));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setAdapter(adapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : TabLayout(android.support.design.widget.TabLayout) SearchFragment(com.lapism.searchview.sample.view.SearchFragment) ViewPager(android.support.v4.view.ViewPager) FragmentAdapter(com.lapism.searchview.sample.view.FragmentAdapter)

Example 48 with TabLayout

use of android.support.design.widget.TabLayout in project material-components-android by material-components.

the class TabLayoutActions method setupWithViewPager.

/** Wires <code>TabLayout</code> to <code>ViewPager</code> content. */
public static ViewAction setupWithViewPager(@Nullable final ViewPager viewPager) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isDisplayingAtLeast(90);
        }

        @Override
        public String getDescription() {
            return "Setup with ViewPager content";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            TabLayout tabLayout = (TabLayout) view;
            tabLayout.setupWithViewPager(viewPager);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) TabLayout(android.support.design.widget.TabLayout) UiController(android.support.test.espresso.UiController) View(android.view.View)

Example 49 with TabLayout

use of android.support.design.widget.TabLayout in project material-components-android by material-components.

the class TabLayoutActions method setScrollPosition.

/**
   * Calls <code>setScrollPosition(position, positionOffset, true)</code> on the <code>TabLayout
   * </code>
   */
public static ViewAction setScrollPosition(final int position, final float positionOffset) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(TabLayout.class);
        }

        @Override
        public String getDescription() {
            return "setScrollPosition(" + position + ", " + positionOffset + ", true)";
        }

        @Override
        public void perform(UiController uiController, View view) {
            TabLayout tabs = (TabLayout) view;
            tabs.setScrollPosition(position, positionOffset, true);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) TabLayout(android.support.design.widget.TabLayout) UiController(android.support.test.espresso.UiController) View(android.view.View)

Example 50 with TabLayout

use of android.support.design.widget.TabLayout in project material-components-android by material-components.

the class TestUtilsActions method addTabs.

/** Adds tabs to {@link TabLayout} */
public static ViewAction addTabs(final String... tabs) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(TabLayout.class);
        }

        @Override
        public String getDescription() {
            return "TabLayout add tabs";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            TabLayout tabLayout = (TabLayout) view;
            for (int i = 0; i < tabs.length; i++) {
                tabLayout.addTab(tabLayout.newTab().setText(tabs[i]));
            }
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) TabLayout(android.support.design.widget.TabLayout) UiController(android.support.test.espresso.UiController) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

TabLayout (android.support.design.widget.TabLayout)75 View (android.view.View)33 ViewPager (android.support.v4.view.ViewPager)28 Toolbar (android.support.v7.widget.Toolbar)17 TextView (android.widget.TextView)13 Intent (android.content.Intent)12 ActionBar (android.support.v7.app.ActionBar)10 RecyclerView (android.support.v7.widget.RecyclerView)10 Fragment (android.support.v4.app.Fragment)8 ImageView (android.widget.ImageView)8 Test (org.junit.Test)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 UiController (android.support.test.espresso.UiController)7 ViewAction (android.support.test.espresso.ViewAction)7 AppBarLayout (android.support.design.widget.AppBarLayout)6 NavigationView (android.support.design.widget.NavigationView)6 ViewGroup (android.view.ViewGroup)6 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)5 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)5 PagerAdapter (android.support.v4.view.PagerAdapter)4