use of android.support.v4.app.FragmentStatePagerAdapter in project making-apps-beautiful by ankurkotwal.
the class ArticleDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_article_detail);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int i) {
Bundle arguments = new Bundle();
arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
ArticleDetailFragment fragment = new ArticleDetailFragment();
fragment.setArguments(arguments);
return fragment;
}
@Override
public int getCount() {
return DummyContent.ITEMS.size();
}
});
pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
if (DummyContent.ITEMS.get(i).id.equals(startId)) {
pager.setCurrentItem(i);
return;
}
}
}
use of android.support.v4.app.FragmentStatePagerAdapter in project RoboBinding-gallery by RoboBinding.
the class ViewPagerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewPager viewPager = new ViewPager(this);
viewPager.setId(R.id.viewPager);
setContentView(viewPager);
final MemoryProductStore productStore = MemoryProductStore.getInstance();
FragmentManager fm = getSupportFragmentManager();
viewPager.setAdapter(new FragmentStatePagerAdapter(fm) {
@Override
public int getCount() {
return productStore.size();
}
@Override
public Fragment getItem(int index) {
return FragmentDemo.newInstance(index);
}
});
int selectedProductIndex = getIntent().getIntExtra(FragmentDemo.EXTRA_PRODUCT_INDEX, 0);
viewPager.setCurrentItem(selectedProductIndex);
}
use of android.support.v4.app.FragmentStatePagerAdapter in project Fragmentation by YoKeyword.
the class FragmentationDelegate method findStackFragment.
/**
* find Fragment from FragmentStack
*/
@SuppressWarnings("unchecked")
<T extends SupportFragment> T findStackFragment(Class<T> fragmentClass, String toFragmentTag, FragmentManager fragmentManager) {
fragmentManager = checkFragmentManager(fragmentManager, null);
if (fragmentManager == null)
return null;
Fragment fragment = null;
if (toFragmentTag == null) {
// 如果是 查找Fragment时,则有可能是在FragmentPagerAdapter/FragmentStatePagerAdapter中,这种情况下,
// 它们的Tag是以android:switcher开头,所以这里我们使用下面的方式
List<Fragment> fragmentList = fragmentManager.getFragments();
if (fragmentList == null)
return null;
int sizeChildFrgList = fragmentList.size();
for (int i = sizeChildFrgList - 1; i >= 0; i--) {
Fragment brotherFragment = fragmentList.get(i);
if (brotherFragment instanceof SupportFragment && brotherFragment.getClass().getName().equals(fragmentClass.getName())) {
fragment = brotherFragment;
break;
}
}
} else {
fragment = fragmentManager.findFragmentByTag(toFragmentTag);
}
if (fragment == null) {
return null;
}
return (T) fragment;
}
use of android.support.v4.app.FragmentStatePagerAdapter in project Timber by naman14.
the class ArtistBioFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_artist_bio, container, false);
Artist artist = ArtistLoader.getArtist(getActivity(), artistID);
LastFmClient.getInstance(getActivity()).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
}
@Override
public void artistInfoFailed() {
}
});
final MultiViewPager pager = (MultiViewPager) rootView.findViewById(R.id.tagspager);
final FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getActivity().getSupportFragmentManager()) {
@Override
public int getCount() {
return 20;
}
@Override
public Fragment getItem(int position) {
return ArtistTagFragment.newInstance(position);
}
};
pager.setAdapter(adapter);
return rootView;
}
use of android.support.v4.app.FragmentStatePagerAdapter in project Timber by naman14.
the class StyleSelectorFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_style_selector, container, false);
if (ACTION.equals(Constants.SETTINGS_STYLE_SELECTOR_NOWPLAYING)) {
}
pager = (MultiViewPager) rootView.findViewById(R.id.pager);
adapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {
@Override
public int getCount() {
return 6;
}
@Override
public Fragment getItem(int position) {
selectorFragment = SubStyleSelectorFragment.newInstance(position, ACTION);
return selectorFragment;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
};
pager.setAdapter(adapter);
scrollToCurrentStyle();
return rootView;
}
Aggregations