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, final boolean autoRefresh) {
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, autoRefresh);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.design.widget.TabLayout in project material-components-android by material-components.
the class TabLayoutActions method setTabMode.
/** Sets the specified tab mode in the <code>TabLayout</code>. */
public static ViewAction setTabMode(final int tabMode) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "Sets tab mode";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TabLayout tabLayout = (TabLayout) view;
tabLayout.setTabMode(tabMode);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.design.widget.TabLayout in project material-components-android by material-components.
the class TabLayoutActions method selectTab.
/** Selects the specified tab in the <code>TabLayout</code>. */
public static ViewAction selectTab(final int tabIndex) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayingAtLeast(90);
}
@Override
public String getDescription() {
return "Selects tab";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TabLayout tabLayout = (TabLayout) view;
tabLayout.getTabAt(tabIndex).select();
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.design.widget.TabLayout in project quickstart-android by firebase.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the adapter that will return a fragment for each section
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
private final Fragment[] mFragments = new Fragment[] { new RecentPostsFragment(), new MyPostsFragment(), new MyTopPostsFragment() };
private final String[] mFragmentNames = new String[] { getString(R.string.heading_recent), getString(R.string.heading_my_posts), getString(R.string.heading_my_top_posts) };
@Override
public Fragment getItem(int position) {
return mFragments[position];
}
@Override
public int getCount() {
return mFragments.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentNames[position];
}
};
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
// Button launches NewPostActivity
findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, NewPostActivity.class));
}
});
}
use of android.support.design.widget.TabLayout in project Android-skin-support by ximsfei.
the class MainActivity method configFragments.
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);
}
Aggregations