本文整理匯總了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;
}
};
}
示例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);
}
}
}
});
}
示例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;
}
示例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);
}
示例5: getPagerAdapter
import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
@Override
protected FragmentPagerAdapter getPagerAdapter()
{
if (adapter == null)
adapter = new TabsAdapter(getFragmentManager(), getViewPager());
return adapter;
}
示例6: getPagerAdapter
import android.support.v13.app.FragmentPagerAdapter; //導入依賴的package包/類
@Override
protected FragmentPagerAdapter getPagerAdapter()
{
if (adapter == null)
adapter = new TabsAdapter(this, getFragmentManager(), getPageIndicator());
return adapter;
}
示例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);
}