Search in sources :

Example 16 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project FolderLayout by kyze8439690.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mFolderLayout = (FolderLayout) findViewById(R.id.folder_layout);
    text1 = (TextView) findViewById(R.id.item1);
    text2 = (TextView) findViewById(R.id.item2);
    text3 = (TextView) findViewById(R.id.item3);
    text4 = (TextView) findViewById(R.id.item4);
    text1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mFolderLayout.toggleItem(3);
        }
    });
    text2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mFolderLayout.toggleItem(2);
        }
    });
    text3.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mFolderLayout.toggleItem(1);
        }
    });
    text4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mFolderLayout.toggleItem(0);
        }
    });
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return new ListFragment();
        }

        @Override
        public int getCount() {
            return 3;
        }
    });
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new String[] { "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item", "list item" });
    mListView = (ListView) findViewById(R.id.list);
    mListView.setAdapter(adapter);
    mGridView = (GridView) findViewById(R.id.grid);
    mGridView.setAdapter(adapter);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ListFragment(android.support.v4.app.ListFragment) GridView(android.widget.GridView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) ListFragment(android.support.v4.app.ListFragment) Fragment(android.support.v4.app.Fragment) ArrayAdapter(android.widget.ArrayAdapter)

Example 17 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project FishChatAndroid by oikomi.

the class ChatMainActivity method initView.

private void initView() {
    mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
    mChatTextView = (TextView) findViewById(R.id.id_tv_chat);
    mFriendTextView = (TextView) findViewById(R.id.id_tv_friend);
    mContactTextView = (TextView) findViewById(R.id.id_tv_contact);
    mMeTextView = (TextView) findViewById(R.id.id_tv_me);
    mChatLinearLayout = (LinearLayout) findViewById(R.id.id_ll_chat);
    mDatas = new ArrayList<Fragment>();
    mDatas.add(tab01);
    mDatas.add(tab02);
    mDatas.add(tab03);
    mDatas.add(tab04);
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mDatas.size();
        }

        @Override
        public Fragment getItem(int arg0) {
            return mDatas.get(arg0);
        }
    };
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            resetTextView();
            switch(position) {
                case 0:
                    if (mBadgeView != null) {
                        mChatLinearLayout.removeView(mBadgeView);
                    }
                    mBadgeView = new BadgeView(ChatMainActivity.this);
                    mBadgeView.setBadgeCount(7);
                    mChatLinearLayout.addView(mBadgeView);
                    mChatTextView.setTextColor(Color.parseColor("#008000"));
                    break;
                case 1:
                    mContactTextView.setTextColor(Color.parseColor("#008000"));
                    break;
                case 2:
                    mFriendTextView.setTextColor(Color.parseColor("#008000"));
                    break;
                case 3:
                    mMeTextView.setTextColor(Color.parseColor("#008000"));
                    break;
            }
            mCurrentPageIndex = position;
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPx) {
            Log.e("TAG", position + " , " + positionOffset + " , " + positionOffsetPx);
            LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) mTabline.getLayoutParams();
            if (// 0->1
            mCurrentPageIndex == 0 && position == 0) {
                lp.leftMargin = (int) (positionOffset * mScreen1_4 + mCurrentPageIndex * mScreen1_4);
            } else if (// 1->0
            mCurrentPageIndex == 1 && position == 0) {
                lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset - 1) * mScreen1_4);
            } else if (// 1->2
            mCurrentPageIndex == 1 && position == 1) {
                lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + positionOffset * mScreen1_4);
            } else if (// 2->1
            mCurrentPageIndex == 2 && position == 1) {
                lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset - 1) * mScreen1_4);
            } else if (// 2->3
            mCurrentPageIndex == 2 && position == 2) {
                lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset) * mScreen1_4);
            } else if (// 3->2
            mCurrentPageIndex == 3 && position == 1) {
                lp.leftMargin = (int) (mCurrentPageIndex * mScreen1_4 + (positionOffset - 1) * mScreen1_4);
            }
            mTabline.setLayoutParams(lp);
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) OnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener) BadgeView(com.jauker.widget.BadgeView) Fragment(android.support.v4.app.Fragment) LinearLayout(android.widget.LinearLayout)

Example 18 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project StickerCamera by Skykai521.

the class AlbumActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_album);
    ButterKnife.inject(this);
    albums = ImageUtils.findGalleries(this, paths, 0);
    //ViewPagerçš„adapter
    FragmentPagerAdapter adapter = new TabPageIndicatorAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    tab.setViewPager(pager);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter)

Example 19 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project RxJavaSamples by rengwuxian.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(toolBar);
    viewPager.setAdapter(new FragmentPagerAdapter(getFragmentManager()) {

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

        @Override
        public Fragment getItem(int position) {
            switch(position) {
                case 0:
                    return new ElementaryFragment();
                case 1:
                    return new MapFragment();
                case 2:
                    return new ZipFragment();
                case 3:
                    return new TokenFragment();
                case 4:
                    return new TokenAdvancedFragment();
                case 5:
                    return new CacheFragment();
                default:
                    return new ElementaryFragment();
            }
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch(position) {
                case 0:
                    return getString(R.string.title_elementary);
                case 1:
                    return getString(R.string.title_map);
                case 2:
                    return getString(R.string.title_zip);
                case 3:
                    return getString(R.string.title_token);
                case 4:
                    return getString(R.string.title_token_advanced);
                case 5:
                    return getString(R.string.title_cache);
                default:
                    return getString(R.string.title_elementary);
            }
        }
    });
    tabLayout.setupWithViewPager(viewPager);
}
Also used : TokenFragment(com.rengwuxian.rxjavasamples.module.token_4.TokenFragment) ZipFragment(com.rengwuxian.rxjavasamples.module.zip_3.ZipFragment) FragmentPagerAdapter(android.support.v13.app.FragmentPagerAdapter) MapFragment(com.rengwuxian.rxjavasamples.module.map_2.MapFragment) CacheFragment(com.rengwuxian.rxjavasamples.module.cache_6.CacheFragment) Fragment(android.app.Fragment) TokenFragment(com.rengwuxian.rxjavasamples.module.token_4.TokenFragment) ZipFragment(com.rengwuxian.rxjavasamples.module.zip_3.ZipFragment) CacheFragment(com.rengwuxian.rxjavasamples.module.cache_6.CacheFragment) MapFragment(com.rengwuxian.rxjavasamples.module.map_2.MapFragment) ElementaryFragment(com.rengwuxian.rxjavasamples.module.elementary_1.ElementaryFragment) TokenAdvancedFragment(com.rengwuxian.rxjavasamples.module.token_advanced_5.TokenAdvancedFragment) TokenAdvancedFragment(com.rengwuxian.rxjavasamples.module.token_advanced_5.TokenAdvancedFragment) ElementaryFragment(com.rengwuxian.rxjavasamples.module.elementary_1.ElementaryFragment)

Example 20 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project ViewPagerIndicator by JakeWharton.

the class SampleTabsStyled method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_tabs);
    FragmentPagerAdapter adapter = new GoogleMusicAdapter(getSupportFragmentManager());
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
    indicator.setViewPager(pager);
}
Also used : TabPageIndicator(com.viewpagerindicator.TabPageIndicator) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ViewPager(android.support.v4.view.ViewPager)

Aggregations

FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)29 Fragment (android.support.v4.app.Fragment)20 ViewPager (android.support.v4.view.ViewPager)8 View (android.view.View)5 Intent (android.content.Intent)3 TabLayout (android.support.design.widget.TabLayout)3 TabPageIndicator (com.viewpagerindicator.TabPageIndicator)3 Toolbar (android.support.v7.widget.Toolbar)2 TextView (android.widget.TextView)2 PageIndicator (com.viewpagerindicator.PageIndicator)2 SuppressLint (android.annotation.SuppressLint)1 Fragment (android.app.Fragment)1 FragmentPagerAdapter (android.support.v13.app.FragmentPagerAdapter)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ListFragment (android.support.v4.app.ListFragment)1 PagerAdapter (android.support.v4.view.PagerAdapter)1 OnPageChangeListener (android.support.v4.view.ViewPager.OnPageChangeListener)1 RecyclerView (android.support.v7.widget.RecyclerView)1 DisplayMetrics (android.util.DisplayMetrics)1