Search in sources :

Example 26 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project ABPlayer by winkstu.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // 无标题
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    FragmentPagerAdapter adapter = new MainTabAdapter(getSupportFragmentManager());
    // 视图切换器
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setOffscreenPageLimit(1);
    pager.setAdapter(adapter);
    // 页面指示器
    PageIndicator indicator = (PageIndicator) findViewById(R.id.indicator);
    indicator.setViewPager(pager);
    /*if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new SubareaFragment())
                    .commit();
        }*/
    AdManager.getInstance(this).init("118250e2aa39dea9", "bc5f4490f33da8e6", false);
    SpotManager.getInstance(this).loadSpotAds();
    SpotManager.getInstance(this).setAnimationType(SpotManager.ANIM_ADVANCE);
    SpotManager.getInstance(this).setSpotOrientation(SpotManager.ORIENTATION_PORTRAIT);
    AdManager.getInstance(this).setUserDataCollect(true);
}
Also used : PageIndicator(com.viewpagerindicator.PageIndicator) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ViewPager(android.support.v4.view.ViewPager) MainTabAdapter(com.vanco.abplayer.adapter.MainTabAdapter)

Example 27 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project Android-SpinKit by ybq.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTabLayout = (TabLayout) findViewById(R.id.tabs);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        String[] titles = new String[] { "page1", "page2" };

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return Page1Fragment.newInstance();
            } else {
                return Page2Fragment.newInstance();
            }
        }

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

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
    });
    mTabLayout.setupWithViewPager(mViewPager);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Fragment(android.support.v4.app.Fragment)

Example 28 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project SeaStar by 13120241790.

the class MainActivity method initView.

private void initView(Fragment mConversationList) {
    //颜色变化
    mRuPengView = (TextView) this.findViewById(R.id.tv_rupeng);
    mConversationListView = (TextView) this.findViewById(R.id.tv_message);
    mContactView = (TextView) this.findViewById(R.id.tv_friend);
    mSettingView = (TextView) this.findViewById(R.id.tv_setting);
    LRuPeng = (LinearLayout) findViewById(R.id.ll_rupeng);
    LConversationList = (RelativeLayout) findViewById(R.id.ll_chat);
    mUnreadCount = (DragPointView) findViewById(R.id.ss_unreadcount);
    LContact = (LinearLayout) findViewById(R.id.ll_friend);
    LSetting = (LinearLayout) findViewById(R.id.ll_setting);
    mSealIcon = (ImageView) findViewById(R.id.main_seal);
    mSealIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_rong_abnormal));
    mMessageIcon = (ImageView) findViewById(R.id.main_message);
    mFriends = (ImageView) findViewById(R.id.main_friends);
    onlineService = (ImageView) findViewById(R.id.online_service);
    onlineService.setOnClickListener(this);
    mMy = (ImageView) findViewById(R.id.main_my);
    LRuPeng.setOnClickListener(this);
    LConversationList.setOnClickListener(this);
    LConversationList.setOnLongClickListener(this);
    LContact.setOnClickListener(this);
    LSetting.setOnClickListener(this);
    mUnreadCount.setOnClickListener(this);
    mUnreadCount.setDragListencer(this);
    mViewPager = (ViewPager) findViewById(R.id.rc_viewpager);
    mFriendFragment = FriendsFragment.getInstance();
    mFragment.add(SealFragment.getInstance());
    mFragment.add(mConversationList);
    if (mFriendFragment != null) {
        mFragment.add(mFriendFragment);
    }
    mFragment.add(MineFragment.getInstance());
    mFragmentPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return mFragment.get(position);
        }

        @Override
        public int getCount() {
            return mFragment.size();
        }
    };
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOffscreenPageLimit(4);
    mViewPager.setOnPageChangeListener(this);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ConversationListFragment(io.rong.imkit.fragment.ConversationListFragment) FriendsFragment(com.rongseal.fragment.FriendsFragment) SealFragment(com.rongseal.fragment.SealFragment) Fragment(android.support.v4.app.Fragment) MineFragment(com.rongseal.fragment.MineFragment)

Example 29 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project BookReader by JustWayward.

the class MainActivity method initDatas.

@Override
public void initDatas() {
    startService(new Intent(this, DownloadBookService.class));
    mTencent = Tencent.createInstance("1105670298", MainActivity.this);
    mDatas = Arrays.asList(getResources().getStringArray(R.array.home_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(new RecommendFragment());
    mTabContents.add(new CommunityFragment());
    mTabContents.add(new FindFragment());
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

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

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
Also used : DownloadBookService(com.justwayward.reader.service.DownloadBookService) RecommendFragment(com.justwayward.reader.ui.fragment.RecommendFragment) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) CommunityFragment(com.justwayward.reader.ui.fragment.CommunityFragment) Intent(android.content.Intent) FindFragment(com.justwayward.reader.ui.fragment.FindFragment) Fragment(android.support.v4.app.Fragment) CommunityFragment(com.justwayward.reader.ui.fragment.CommunityFragment) RecommendFragment(com.justwayward.reader.ui.fragment.RecommendFragment) FindFragment(com.justwayward.reader.ui.fragment.FindFragment)

Example 30 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project BookReader by JustWayward.

the class BookDetailCommunityActivity method initDatas.

@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.bookdetail_community_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(BookDetailDiscussionFragment.newInstance(bookId));
    mTabContents.add(BookDetailReviewFragment.newInstance(bookId));
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

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

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) BookDetailReviewFragment(com.justwayward.reader.ui.fragment.BookDetailReviewFragment) BookDetailDiscussionFragment(com.justwayward.reader.ui.fragment.BookDetailDiscussionFragment) Fragment(android.support.v4.app.Fragment)

Aggregations

FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)29 Fragment (android.support.v4.app.Fragment)23 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 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 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 Bundle (android.os.Bundle)1 FragmentPagerAdapter (android.support.v13.app.FragmentPagerAdapter)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)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