Search in sources :

Example 41 with PagerAdapter

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();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 42 with PagerAdapter

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));
    }
}
Also used : ViewPager(android.support.v4.view.ViewPager) Toolbar(android.support.v7.widget.Toolbar)

Example 43 with PagerAdapter

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);
}
Also used : ViewPager(android.support.v4.view.ViewPager) SuppressLint(android.annotation.SuppressLint) Toolbar(android.support.v7.widget.Toolbar)

Example 44 with PagerAdapter

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));
    }
}
Also used : ViewPager(android.support.v4.view.ViewPager) Toolbar(android.support.v7.widget.Toolbar)

Example 45 with PagerAdapter

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);
        }
    }
}
Also used : TextView(android.widget.TextView) HorizontalScrollView(android.widget.HorizontalScrollView) TextView(android.widget.TextView) View(android.view.View) PagerAdapter(android.support.v4.view.PagerAdapter) LinearLayout(android.widget.LinearLayout)

Aggregations

PagerAdapter (android.support.v4.view.PagerAdapter)111 View (android.view.View)49 ViewPager (android.support.v4.view.ViewPager)44 TextView (android.widget.TextView)33 ViewGroup (android.view.ViewGroup)19 HorizontalScrollView (android.widget.HorizontalScrollView)19 LinearLayout (android.widget.LinearLayout)13 Toolbar (android.support.v7.widget.Toolbar)12 ImageView (android.widget.ImageView)11 TabLayout (android.support.design.widget.TabLayout)10 ArrayList (java.util.ArrayList)9 RecyclerView (android.support.v7.widget.RecyclerView)8 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)7 AppBarLayout (android.support.design.widget.AppBarLayout)6 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)6 MenuItem (android.view.MenuItem)5 ImageButton (android.widget.ImageButton)5 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)4 LargeTest (android.support.test.filters.LargeTest)4 MediumTest (android.support.test.filters.MediumTest)4