use of android.support.v4.app.Fragment in project hellocharts-android by lecho.
the class ViewPagerChartsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_pager_charts);
// Set up the action bar.
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
}
}
use of android.support.v4.app.Fragment in project ParallaxSplash by leerduo.
the class ParallaxContainer method setUp.
/**
* 指定引导页的所有页面布局文件
*
* @param childIds
*/
public void setUp(int... childIds) {
//根据布局文件数组,初始化所有的Fragment
fragments = new ArrayList<>();
for (int i = 0; i < childIds.length; i++) {
ParallaxFragment f = new ParallaxFragment();
Bundle args = new Bundle();
//页面索引
args.putInt("index", i);
//Fragment中需要加载的布局文件id
args.putInt("layoutId", childIds[i]);
f.setArguments(args);
fragments.add(f);
}
//实例化适配器
MainActivity activity = (MainActivity) getContext();
adapter = new ParallaxPagerAdapter(activity.getSupportFragmentManager(), fragments);
//实例化ViewPager
ViewPager vp = new ViewPager(getContext());
vp.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
vp.setId(R.id.parallax_pager);
//绑定
vp.setAdapter(adapter);
addView(vp, 0);
//在翻页的过程中,不断根据视图的标签中对应的动画参数,改变视图的位置或者透明度
vp.setOnPageChangeListener(this);
}
use of android.support.v4.app.Fragment in project cube-sdk by liaohuqiu.
the class CubeFragmentActivity method goToThisFragment.
private void goToThisFragment(FragmentParam param) {
int containerId = getFragmentContainerId();
Class<?> cls = param.cls;
if (cls == null) {
return;
}
try {
String fragmentTag = getFragmentTag(param);
FragmentManager fm = getSupportFragmentManager();
if (DEBUG) {
CLog.d(LOG_TAG, "before operate, stack entry count: %s", fm.getBackStackEntryCount());
}
CubeFragment fragment = (CubeFragment) fm.findFragmentByTag(fragmentTag);
if (fragment == null) {
fragment = (CubeFragment) cls.newInstance();
}
if (mCurrentFragment != null && mCurrentFragment != fragment) {
mCurrentFragment.onLeave();
}
fragment.onEnter(param.data);
FragmentTransaction ft = fm.beginTransaction();
if (fragment.isAdded()) {
if (DEBUG) {
CLog.d(LOG_TAG, "%s has been added, will be shown again.", fragmentTag);
}
ft.show(fragment);
} else {
if (DEBUG) {
CLog.d(LOG_TAG, "%s is added.", fragmentTag);
}
ft.add(containerId, fragment, fragmentTag);
}
mCurrentFragment = fragment;
ft.addToBackStack(fragmentTag);
ft.commitAllowingStateLoss();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
mCloseWarned = false;
}
use of android.support.v4.app.Fragment in project android-topeka by googlesamples.
the class CategorySelectionActivity method attachCategoryGridFragment.
private void attachCategoryGridFragment() {
FragmentManager supportFragmentManager = getSupportFragmentManager();
Fragment fragment = supportFragmentManager.findFragmentById(R.id.category_container);
if (!(fragment instanceof CategorySelectionFragment)) {
fragment = CategorySelectionFragment.newInstance();
}
supportFragmentManager.beginTransaction().replace(R.id.category_container, fragment).commit();
setProgressBarVisibility(View.GONE);
}
use of android.support.v4.app.Fragment in project android-advancedrecyclerview by h6ah4i.
the class VerticalSwipeableExampleActivity method onNotifyItemPinnedDialogDismissed.
// implements ItemPinnedMessageDialogFragment.EventListener
@Override
public void onNotifyItemPinnedDialogDismissed(int itemPosition, boolean ok) {
final Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_LIST_VIEW);
getDataProvider().getItem(itemPosition).setPinned(ok);
((VerticalSwipeableExampleFragment) fragment).notifyItemChanged(itemPosition);
}
Aggregations