use of android.support.v4.view.PagerAdapter in project LuaViewSDK by alibaba.
the class LVCustomViewPagerIndicator method setViewPager.
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
use of android.support.v4.view.PagerAdapter in project UltimateAndroid by cymcsg.
the class MaterialTabTextActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.material_tab_text_activity_main);
Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
this.setSupportActionBar(toolbar);
tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost);
pager = (ViewPager) this.findViewById(R.id.pager);
// init view pager
adapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// when user do a swipe the selected tab change
tabHost.setSelectedNavigationItem(position);
}
});
// insert all tabs from pagerAdapter data
for (int i = 0; i < adapter.getCount(); i++) {
tabHost.addTab(tabHost.newTab().setText(adapter.getPageTitle(i)).setTabListener(this));
}
}
use of android.support.v4.view.PagerAdapter in project UltimateAndroid by cymcsg.
the class MaterialTabsWithIconsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.material_tab_activity_main);
res = this.getResources();
// init toolbar (old action bar)
Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.WHITE);
this.setSupportActionBar(toolbar);
tabHost = (MaterialTabHost) this.findViewById(R.id.materialTabHost);
pager = (ViewPager) this.findViewById(R.id.viewpager);
// init view pager
pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// when user do a swipe the selected tab change
tabHost.setSelectedNavigationItem(position);
}
});
// insert all tabs from pagerAdapter data
for (int i = 0; i < pagerAdapter.getCount(); i++) {
tabHost.addTab(tabHost.newTab().setIcon(getIcon(i)).setTabListener(this));
}
//tabHost.setAccentColor(Color.BLUE);
}
use of android.support.v4.view.PagerAdapter in project MaterialTabs by neokree.
the class IconTabActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_icons);
res = this.getResources();
// init toolbar (old action bar)
Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.WHITE);
this.setSupportActionBar(toolbar);
tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost);
pager = (ViewPager) this.findViewById(R.id.pager);
// init view pager
pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// when user do a swipe the selected tab change
tabHost.setSelectedNavigationItem(position);
}
});
// insert all tabs from pagerAdapter data
for (int i = 0; i < pagerAdapter.getCount(); i++) {
tabHost.addTab(tabHost.newTab().setIcon(getIcon(i)).setTabListener(this));
}
}
use of android.support.v4.view.PagerAdapter in project CompactCalendarView by SundeepK.
the class SlidingTabLayout method populateTabStrip.
private void populateTabStrip() {
final PagerAdapter adapter = mViewPager.getAdapter();
final OnClickListener tabClickListener = new TabClickListener();
for (int i = 0; i < adapter.getCount(); i++) {
View tabView = null;
TextView tabTitleView = null;
if (mTabViewLayoutId != 0) {
// If there is a custom tab view layout id set, try and inflate it
tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
}
if (tabView == null) {
tabView = createDefaultTabView(getContext());
}
if (tabTitleView == null && TextView.class.isInstance(tabView)) {
tabTitleView = (TextView) tabView;
}
if (mDistributeEvenly) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}
tabTitleView.setText(adapter.getPageTitle(i));
tabView.setOnClickListener(tabClickListener);
String desc = mContentDescriptions.get(i, null);
if (desc != null) {
tabView.setContentDescription(desc);
}
mTabStrip.addView(tabView);
if (i == mViewPager.getCurrentItem()) {
tabView.setSelected(true);
}
}
}
Aggregations