當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentPagerAdapter類代碼示例

本文整理匯總了Java中android.support.v13.app.FragmentPagerAdapter的典型用法代碼示例。如果您正苦於以下問題:Java FragmentPagerAdapter類的具體用法?Java FragmentPagerAdapter怎麽用?Java FragmentPagerAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FragmentPagerAdapter類屬於android.support.v13.app包,在下文中一共展示了FragmentPagerAdapter類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAdapter

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
private PagerAdapter createAdapter() {
    return new FragmentPagerAdapter(getFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0: return QuizFragment.newInstance();
                case 1: return FiltersFragment.newInstance();
                case 2: return MatchesFragment.newInstance();
                case 3: return MyProfileFragment.newInstance();
                case 4: return SettingsFragment.newInstance();
                default: return null;
            }
        }

        @Override
        public int getCount() {
            return 5;
        }
    };
}
 
開發者ID:KwalaGroup,項目名稱:Android-Client,代碼行數:21,代碼來源:MainActivity.java

示例2: setFragmentAdapter

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
public void setFragmentAdapter(@NonNull FragmentPagerAdapter adapter,
                               @NonNull FragmentManager fm) {
    mOriginalAdapter = adapter;
    mInternalFragmentPagerAdapter = new InternalFragmentPagerAdapter(fm);

    super.setAdapter(mInternalFragmentPagerAdapter);
    mCurrentPosition = mOriginalAdapter.getCount() * 3 / 2;
    super.setCurrentItem(mOriginalAdapter.getCount() * 3 / 2, false);

    addOnPageChangeListener(new SimpleOnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int state) {
            if (state == SCROLL_STATE_IDLE) {
                int size = mOriginalAdapter.getCount();
                if (mCurrentPosition < size / 2 + size % 2) {
                    mInternalFragmentPagerAdapter.shiftIndex(false);
                } else if (mCurrentPosition > size * 2 + size / 2) {
                    mInternalFragmentPagerAdapter.shiftIndex(true);
                }
            }
        }
    });
}
 
開發者ID:sanyuzhang,項目名稱:CircularViewPager,代碼行數:24,代碼來源:CircularViewPager.java

示例3: getScrollY

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
public int getScrollY()
{
	IKlyphFragment f = (IKlyphFragment) ((FragmentPagerAdapter) getPagerAdapter()).getItem(getViewPager().getCurrentItem());

	if (f == null || f.getListView() == null)
		return 0;

	listPadding = f.getListView().getPaddingTop();

	View c = f.getListView().getChildAt(0);
	if (c == null)
	{
		return 0;
	}

	int firstVisiblePosition = f.getListView().getFirstVisiblePosition();
	int top = c.getTop();

	int headerHeight = 0;
	if (firstVisiblePosition >= 1)
	{
		headerHeight = fakeHeaderHeight;
	}
	// Log.d("UserActivity", "getScrollY: " + top + " " + headerHeight);
	return -top + firstVisiblePosition * c.getHeight() + headerHeight + listPadding;
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:27,代碼來源:ProfileActivity.java

示例4: onCreate

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {

	super.onCreate(savedInstanceState);
	setContentView(R.layout.detail_activity);

	Intent intent = getIntent();
	list = (ArrayList<Item>) intent.getSerializableExtra(KEY_LIST);

	fragments = new ArrayList<DetailFragment>();
	for (Item item : list) {
		fragments.add(new DetailFragment(item));
	}

	final ViewPager pager = (ViewPager) findViewById(R.id.pager);
	pager.setAdapter(new FragmentPagerAdapter(getFragmentManager()) {
		@Override
		public int getCount() {
			return list.size();
		}

		@Override
		public Fragment getItem(int position) {
			// return new DetailFragment(list.get(position));
			return fragments.get(position);
			// return new LabelListFragment(DummyGenerator.getLabelList());
		}
	});
	pager.setCurrentItem(intent.getIntExtra(KEY_POSITION, 0));

	ActionBar actionBar = getActionBar();
	actionBar.setDisplayHomeAsUpEnabled(true);
}
 
開發者ID:dekrandroid,項目名稱:android-in-sette-giorni,代碼行數:34,代碼來源:DetailActivity.java

示例5: getPagerAdapter

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
@Override
protected FragmentPagerAdapter getPagerAdapter()
{
	if (adapter == null)
		adapter = new TabsAdapter(getFragmentManager(), getViewPager());

	return adapter;
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:9,代碼來源:AlbumActivity.java

示例6: getPagerAdapter

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
@Override
protected FragmentPagerAdapter getPagerAdapter()
{
	if (adapter == null)
		adapter = new TabsAdapter(this, getFragmentManager(), getPageIndicator());

	return adapter;
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:9,代碼來源:UserActivity.java

示例7: onCreate

import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_viewpager);
		
		FragmentPagerAdapter adapter = new FragmentPagerAdapter(getFragmentManager()) {
			@Override
			public Fragment getItem(int position) {
				switch (position) {
				case 0:
					return MainFragment.getInstance();
				case 1:
					return MovingFragment.getInstance();
				case 2:
					return BehaviorFragment.getInstance();
				case 3:
					return OverlayFragment.getInstance();
//				case 2:
//					return TestingActivity.getInstance();
				}
				return new Fragment();
			}
			
			@Override
			public String getPageTitle(int pos) {
				switch (pos) {
				case 0:
					return getResources().getString(R.string.pref_main_top_title);
				case 1:
					return getResources().getString(R.string.pref_movable_top_title);
				case 2:
					return getResources().getString(R.string.pref_behavior_title);
				case 3:
					return getResources().getString(R.string.pref_overlay_title);
//				case 2:
//					return getResources().getString(R.string.pref_testing_top_title);
				}
				return "";
			}
			
			@Override
			public int getCount() {
				return 4;
			}
		};
		ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
		viewPager.setAdapter(adapter);
		
		PagerTabStrip pts = (PagerTabStrip) findViewById(R.id.pager_title_strip);
		pts.setTabIndicatorColor(0xFF333333);
		pts.setTextColor(0xFF111111);
		pts.setBackgroundColor(Color.TRANSPARENT);
		
		ActionBar bar = getActionBar();
		bar.setBackgroundDrawable(new ColorDrawable(0xFFAA0000)); 
		
		
		testSettings(true);
		
	}
 
開發者ID:shooash,項目名稱:XHFW3,代碼行數:62,代碼來源:MainPreference.java


注:本文中的android.support.v13.app.FragmentPagerAdapter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。