當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。