当前位置: 首页>>代码示例>>Java>>正文


Java FragmentActivity.getSupportFragmentManager方法代码示例

本文整理汇总了Java中android.support.v4.app.FragmentActivity.getSupportFragmentManager方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentActivity.getSupportFragmentManager方法的具体用法?Java FragmentActivity.getSupportFragmentManager怎么用?Java FragmentActivity.getSupportFragmentManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.FragmentActivity的用法示例。


在下文中一共展示了FragmentActivity.getSupportFragmentManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceFragment

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void replaceFragment(FragmentActivity context, Fragment fragment, boolean doAnimate) {
    String TAG = fragment.getClass().toString();
    String backStackName = fragment.getClass().getName();
    FragmentManager manager = context.getSupportFragmentManager();
    boolean fragmentPopped = manager.popBackStackImmediate(backStackName, 0);
    if (!fragmentPopped && context.getSupportFragmentManager().findFragmentByTag(TAG) == null) {
        final android.support.v4.app.FragmentTransaction ft = context.getSupportFragmentManager().beginTransaction();
        if(doAnimate)
            ft.setCustomAnimations(R.anim.enter,R.anim.exit,R.anim.left_to_right,R.anim.right_to_left);
        else
            ft.setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_out);
        ft.replace(R.id.mainfragment, fragment, TAG);
        ft.addToBackStack(backStackName);
        ft.commit();
    }
}
 
开发者ID:Auto-Droid,项目名称:TMDB-App,代码行数:17,代码来源:Utils.java

示例2: holderFragmentFor

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
HolderFragment holderFragmentFor(FragmentActivity activity) {
    FragmentManager fm = activity.getSupportFragmentManager();
    HolderFragment holder = findHolderFragment(fm);
    if (holder != null) {
        return holder;
    }
    holder = mNotCommittedActivityHolders.get(activity);
    if (holder != null) {
        return holder;
    }

    if (!mActivityCallbacksIsAdded) {
        mActivityCallbacksIsAdded = true;
        activity.getApplication().registerActivityLifecycleCallbacks(mActivityCallbacks);
    }
    holder = createHolderFragment(fm);
    mNotCommittedActivityHolders.put(activity, holder);
    return holder;
}
 
开发者ID:JessYanCoding,项目名称:LifecycleModel,代码行数:20,代码来源:HolderFragment.java

示例3: TabListener

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/**
 * Constructor used each time a new tab is created.
 *
 * @param activity The host Activity, used to instantiate the fragment
 * @param tag      The identifier tag for the fragment
 * @param clz      The fragment's Class, used to instantiate the fragment
 */
public TabListener(Activity activity, String tag, Class<T> clz) {
        /*
        if (activity instanceof OverviewActivity) {
            mActivity = (OverviewActivity) activity;
        } else {
            mActivity = (AboutProgramActivity) activity;
        }
        */
    mActivity = (FragmentActivity) activity;
    mTag = tag;
    mClass = clz;

    FragmentManager fragmentManager = mActivity
            .getSupportFragmentManager();
    mFragment = fragmentManager.findFragmentByTag(mTag);
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:24,代码来源:TabListener.java

示例4: changeFragment

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void changeFragment(FragmentActivity activity, Fragment nextFragment, boolean addToBackStack) {
        String name = nextFragment.getClass().getSimpleName();

        final FragmentManager fragmentManager = activity.getSupportFragmentManager();

        final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.setCustomAnimations(R.anim.slide_left_in, R.anim.slide_right_in, R.anim.slide_left_out, R.anim.slide_right_out);

        fragmentTransaction.replace(R.id.frame_content, nextFragment);

        if (addToBackStack) {
            fragmentTransaction.addToBackStack(name);
        }
        try {
            fragmentTransaction.commitAllowingStateLoss();
            fragmentManager.executePendingTransactions();
        } catch (IllegalStateException e) {
        }

}
 
开发者ID:Ubudu,项目名称:GoogleMapsLayout-Android,代码行数:21,代码来源:FragmentUtils.java

示例5: initPageView

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
private void initPageView(){
    FragmentActivity activity = getActivity();
    if(activity == null){
        return;
    }

    if (adapter == null) {
        adapter = new XFragmentAdapter(activity.getSupportFragmentManager(), fragmentList, titles);
    }

    viewPager.setOffscreenPageLimit(3);
    viewPager.setAdapter(adapter);

    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:17,代码来源:HomeFragment.java

示例6: initData

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
@Override
public void initData(Bundle savedInstanceState) {
    FragmentActivity activity = getActivity();
    if(activity == null){
        return;
    }

    for (int i = 0;i < 3;i++){
        Fragment fragment = new AccountDetailFragment();
        ((AccountDetailFragment)fragment).setType(i);
        fragmentList.add(fragment);
    }

    if (adapter == null) {
        adapter = new XFragmentAdapter(activity.getSupportFragmentManager(), fragmentList, titles);
    }

    viewPager.setOffscreenPageLimit(1);
    viewPager.setAdapter(adapter);

    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:24,代码来源:AccountFragment.java

示例7: startLogin

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/***
 * 跳转到登录
 * requestCode=1111
 */
public static void startLogin(FragmentActivity context, ActivityResultListner listener) {
    //先看activity是否添加过该fragment, 添加根据Tag找出 ,没有就添加
    FragmentManager manager = context.getSupportFragmentManager();
    MyFragment myFragment = null;
    Fragment loginf = manager.findFragmentByTag(MyFragment.LOGIN + "");
    if (loginf == null) {
        myFragment = new MyFragment();
        manager.beginTransaction().add(myFragment, MyFragment.LOGIN + "").commit();
        //这句是让commit立即生效,不然运行会报错,fragment还没有被attach
        manager.executePendingTransactions();
    } else {
        myFragment = (MyFragment) loginf;
    }
    //设置监听
    myFragment.setListener(listener);
    Intent intent = new Intent(context, loginActivity.class);
    myFragment.startActivityForResult(intent, MyFragment.LOGIN);
}
 
开发者ID:While1true,项目名称:JSSample,代码行数:23,代码来源:ActivityUtils.java

示例8: skjulMenu

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public void vælgMenu(FragmentActivity akt, int position) {
  //new Exception().printStackTrace();
  MenuElement e = elem.get(position);
  skjulMenu();
  if (e.runnable != null) {
    e.runnable.run();
    sætListemarkering(-1); // Ingen listemarkering
    return;
  }

  sætListemarkering(position);

  try {
    FragmentManager fm = akt.getSupportFragmentManager();
    // Fjern backstak - så vi starter forfra i 'roden'
    fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    Log.d("Venstremenu viser " + e.fragKlasse);
    Basisfragment f = e.fragKlasse.newInstance();
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.indhold_frag, f);
    ft.addToBackStack("Venstremenu");
    ft.commit();
    Sidevisning.vist(f.getClass());
  } catch (Exception e1) {
    Log.rapporterFejl(e1);
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:28,代码来源:Venstremenu_frag.java

示例9: TabsAdapter

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public TabsAdapter(FragmentActivity activity, ActionBar actionBar, ViewPager pager) {
    super(activity.getSupportFragmentManager());
    mContext = activity;
    mActionBar = actionBar;
    mViewPager = pager;
    mViewPager.setAdapter(this);
    mViewPager.setOnPageChangeListener(this);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:9,代码来源:Codecs.java

示例10: setTabData

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/** 关联数据支持同时切换fragments */
public void setTabData(String[] titles, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
    mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
    setTabData(titles);
}
 
开发者ID:Kelvin65535,项目名称:Android_Songshuhui,代码行数:6,代码来源:SegmentTabLayout.java

示例11: setTabData

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/** 关联数据支持同时切换fragments */
public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
    mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
    setTabData(tabEntitys);
}
 
开发者ID:767954322,项目名称:FlycoTabLayout,代码行数:6,代码来源:CommonTabLayout.java

示例12: MyViewPagerAdapter

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public MyViewPagerAdapter(FragmentActivity activity) {
    super(activity.getSupportFragmentManager());
    mContext = activity;
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:5,代码来源:NotebookTabsFragment.java

示例13: callEditDialog

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void callEditDialog(FragmentActivity activity, Fragment fragment, int id, String description, int color) {
    FragmentManager fm = activity.getSupportFragmentManager();
    ItemPickerDialogFragment pickTaskName = ItemPickerDialogFragment.newInstance(id, description, color);
    pickTaskName.setTargetFragment(fragment, EDIT_ITEM);
    pickTaskName.show(fm, "edit_item");
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:7,代码来源:DialogUtils.java

示例14: getMyFragmentManager

import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/**
 * get the support fragment manager
 *
 * @return FragmentManager
 */
protected FragmentManager getMyFragmentManager(FragmentActivity activity) {
    return activity.getSupportFragmentManager();
}
 
开发者ID:YunzhanghuOpen,项目名称:redpacketui-open,代码行数:9,代码来源:RPBaseDialogFragment.java


注:本文中的android.support.v4.app.FragmentActivity.getSupportFragmentManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。