Search in sources :

Example 1 with RelativeLayout

use of carbon.widget.RelativeLayout in project Carbon by ZieIony.

the class TabsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new PagerAdapter() {

        @Override
        public CharSequence getPageTitle(int position) {
            return "Page " + position;
        }

        public View getView(int position, ViewPager pager) {
            return new RelativeLayout(pager.getContext(), null, R.attr.carbon_cardViewStyle);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getCount() {
            return 7;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            ViewPager pager = (ViewPager) container;
            View view = getView(position, pager);
            pager.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object view) {
            ((ViewPager) container).removeView((View) view);
        }
    });
    PagerTabStrip tabs = (PagerTabStrip) findViewById(R.id.pager_title_strip);
    tabs.setViewPager(pager);
}
Also used : ViewGroup(android.view.ViewGroup) RelativeLayout(carbon.widget.RelativeLayout) PagerTabStrip(carbon.widget.PagerTabStrip) ViewPager(carbon.widget.ViewPager) View(android.view.View) PagerAdapter(android.support.v4.view.PagerAdapter)

Aggregations

PagerAdapter (android.support.v4.view.PagerAdapter)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 PagerTabStrip (carbon.widget.PagerTabStrip)1 RelativeLayout (carbon.widget.RelativeLayout)1 ViewPager (carbon.widget.ViewPager)1