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));
}
}
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);
}
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();
}
};
}
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();
}
};
}
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();
}
};
}
Aggregations