use of android.support.v13.app.FragmentPagerAdapter in project BGARefreshLayout-Android by bingoogolapple.
the class BGAStickyNavLayout method regetNestedContentView.
/**
* 重新获取嵌套的内容视图
*/
private void regetNestedContentView() {
int currentItem = mDirectViewPager.getCurrentItem();
PagerAdapter adapter = mDirectViewPager.getAdapter();
if (adapter instanceof FragmentPagerAdapter || adapter instanceof FragmentStatePagerAdapter) {
Fragment item = (Fragment) adapter.instantiateItem(mDirectViewPager, currentItem);
mNestedContentView = item.getView();
// 清空之前的
mNestedNormalView = null;
mNestedAbsListView = null;
mNestedRecyclerView = null;
mNestedScrollView = null;
mNestedWebView = null;
if (mNestedContentView instanceof AbsListView) {
mNestedAbsListView = (AbsListView) mNestedContentView;
mNestedAbsListView.setOnScrollListener(mLvOnScrollListener);
if (!isHeaderViewCompleteInvisible()) {
mNestedAbsListView.setSelection(0);
}
} else if (mNestedContentView instanceof RecyclerView) {
mNestedRecyclerView = (RecyclerView) mNestedContentView;
mNestedRecyclerView.removeOnScrollListener(mRvOnScrollListener);
mNestedRecyclerView.addOnScrollListener(mRvOnScrollListener);
if (!isHeaderViewCompleteInvisible()) {
mNestedRecyclerView.scrollToPosition(0);
}
} else if (mNestedContentView instanceof ScrollView) {
mNestedScrollView = (ScrollView) mNestedContentView;
if (!isHeaderViewCompleteInvisible()) {
mNestedScrollView.scrollTo(mNestedScrollView.getScrollX(), 0);
}
} else if (mNestedContentView instanceof WebView) {
mNestedWebView = (WebView) mNestedContentView;
if (!isHeaderViewCompleteInvisible()) {
mNestedWebView.scrollTo(mNestedWebView.getScrollX(), 0);
}
} else {
mNestedNormalView = mNestedContentView;
}
} else {
throw new IllegalStateException(BGAStickyNavLayout.class.getSimpleName() + "的第三个子控件为ViewPager时,其adapter必须是FragmentPagerAdapter或者FragmentStatePagerAdapter");
}
}
use of android.support.v13.app.FragmentPagerAdapter in project AndroidDevMetrics by frogermcs.
the class MetricsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.adm_activity_metrics);
btnActivities = (Button) findViewById(R.id.btnActivities);
btnDagger2 = (Button) findViewById(R.id.btnDagger2);
vpMetrics = (ViewPager) findViewById(R.id.vpMetrics);
activitiesMetricsFragment = new ActivitiesMetricsFragment();
dagger2MetricsFragment = new Dagger2MetricsFragment();
FragmentPagerAdapter fragmentPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
if (position == 0) {
return activitiesMetricsFragment;
} else if (position == 1) {
return dagger2MetricsFragment;
}
return null;
}
@Override
public int getCount() {
return 2;
}
};
vpMetrics.setAdapter(fragmentPagerAdapter);
vpMetrics.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (position == 0) {
activitiesPageSelected();
} else if (position == 1) {
daggerPageSelected();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
btnActivities.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vpMetrics.setCurrentItem(0);
}
});
btnDagger2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
vpMetrics.setCurrentItem(1);
}
});
activitiesPageSelected();
}
use of android.support.v13.app.FragmentPagerAdapter in project AndroidAutoLayout by hongyangAndroid.
the class CategoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_category);
mTabLayout = (TabLayout) findViewById(R.id.id_tablayout);
mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
return new SimpleFragment();
}
@Override
public CharSequence getPageTitle(int position) {
return mTabTitles[position];
}
@Override
public int getCount() {
return mTabTitles.length;
}
});
mTabLayout.setupWithViewPager(mViewPager);
}
use of android.support.v13.app.FragmentPagerAdapter in project FlowLayout by hongyangAndroid.
the class CategoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_category);
mTabLayout = (TabLayout) findViewById(R.id.id_tablayout);
mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
switch(i) {
case 0:
return new SimpleFragment();
case 1:
return new LimitSelectedFragment();
case 2:
return new EventTestFragment();
case 3:
return new ScrollViewTestFragment();
case 4:
return new SingleChooseFragment();
case 5:
return new GravityFragment();
case 6:
return new ListViewTestFragment();
default:
return new EventTestFragment();
}
}
@Override
public CharSequence getPageTitle(int position) {
return mTabTitles[position];
}
@Override
public int getCount() {
return mTabTitles.length;
}
});
mTabLayout.setupWithViewPager(mViewPager);
}
use of android.support.v13.app.FragmentPagerAdapter in project Android-Boilerplate by hitherejoe.
the class DetailActivity method setupViewPager.
private void setupViewPager() {
mBeaconDetailViewPager.setOffscreenPageLimit(2);
mBeaconDetailViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
String[] titles = getResources().getStringArray(R.array.detail_fragment_titles);
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.films);
case 1:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.vehicles);
case 2:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.species);
case 3:
return DetailFragment.newInstance((ArrayList<String>) mCharacter.starships);
default:
return DetailFragment.newInstance(new ArrayList<String>());
}
}
@Override
public CharSequence getPageTitle(int position) {
return titles[position];
}
@Override
public int getCount() {
return titles.length;
}
});
mTabLayout.setupWithViewPager(mBeaconDetailViewPager);
}
Aggregations