本文整理汇总了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);
}