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


Java FragmentManager.getFragment方法代码示例

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


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

示例1: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.context = getActivity();

    if (savedInstanceState != null) {
        FragmentManager manager = getChildFragmentManager();
        zhihuDailyFragment = (ZhihuDailyFragment) manager.getFragment(savedInstanceState, "zhihu");
        guokrFragment = (GuokrFragment) manager.getFragment(savedInstanceState, "guokr");
        doubanMomentFragment = (DoubanMomentFragment) manager.getFragment(savedInstanceState, "douban");
    } else {
        zhihuDailyFragment = ZhihuDailyFragment.newInstance();
        guokrFragment = GuokrFragment.newInstance();
        doubanMomentFragment = DoubanMomentFragment.newInstance();
    }

    zhihuDailyPresenter = new ZhihuDailyPresenter(context, zhihuDailyFragment);
    guokrPresenter = new GuokrPresenter(context, guokrFragment);
    doubanMomentPresenter = new DoubanMomentPresenter(context, doubanMomentFragment);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:MainFragment.java

示例2: restore

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void restore(FragmentManager fragmentManager, Bundle fragments) {
    mFragments.clear();
    if (fragments != null) {
        Iterable<String> keys = fragments.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                IMasterFragment f = (IMasterFragment) fragmentManager.getFragment(fragments, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:22,代码来源:Records.java

示例3: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        FragmentManager fm = getChildFragmentManager();
        mZhihuFragment = (ZhihuDailyFragment) fm.getFragment(savedInstanceState, ZhihuDailyFragment.class.getSimpleName());
        mDoubanFragment = (DoubanMomentFragment) fm.getFragment(savedInstanceState, DoubanMomentFragment.class.getSimpleName());
        mGuokrFragment = (GuokrHandpickFragment) fm.getFragment(savedInstanceState, GuokrHandpickFragment.class.getSimpleName());
    } else {
        mZhihuFragment = ZhihuDailyFragment.newInstance();
        mDoubanFragment = DoubanMomentFragment.newInstance();
        mGuokrFragment = GuokrHandpickFragment.newInstance();
    }

    new ZhihuDailyPresenter(mZhihuFragment, ZhihuDailyNewsRepository.getInstance(
            ZhihuDailyNewsLocalDataSource.getInstance(getContext()),
            ZhihuDailyNewsRemoteDataSource.getInstance()));

    new DoubanMomentPresenter(mDoubanFragment, DoubanMomentNewsRepository.getInstance(
            DoubanMomentNewsRemoteDataSource.getInstance(),
            DoubanMomentNewsLocalDataSource.getInstance(getContext())));

    new GuokrHandpickPresenter(mGuokrFragment, GuokrHandpickNewsRepository.getInstance(
            GuokrHandpickNewsRemoteDataSource.getInstance(),
            GuokrHandpickNewsLocalDataSource.getInstance(getContext())));
}
 
开发者ID:SpeedPromise,项目名称:L-Assistant,代码行数:27,代码来源:TimelineFragment.java

示例4: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.context = getActivity();

    if (savedInstanceState != null) {
        FragmentManager manager = getChildFragmentManager();
        zhihuDailyFragment = (ZhihuDailyFragment) manager.getFragment(savedInstanceState, "zhihu");
        //guokrFragment = (GuokrFragment) manager.getFragment(savedInstanceState, "guokr");
        doubanMomentFragment = (DoubanMomentFragment) manager.getFragment(savedInstanceState, "douban");
    } else {
        zhihuDailyFragment = ZhihuDailyFragment.newInstance();
        //guokrFragment = GuokrFragment.newInstance();
        doubanMomentFragment = DoubanMomentFragment.newInstance();
    }

    zhihuDailyPresenter = new ZhihuDailyPresenter(context, zhihuDailyFragment);
    //guokrPresenter = new GuokrPresenter(context, guokrFragment);
    doubanMomentPresenter = new DoubanMomentPresenter(context, doubanMomentFragment);

}
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:23,代码来源:MainFragment.java

示例5: onRestoreInstanceState

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onRestoreInstanceState(Bundle inState) {
    super.onRestoreInstanceState(inState);
    FragmentManager fm = getSupportFragmentManager();
    mBookmarkFragment = (BookmarkFragment) fm.getFragment(inState, BOOKMARK_FRAGMENT);
    mTagsFragment = (TagsFragment) fm.getFragment(inState, TAGS_FRAGMENT);
    setupBookmarkFragmentListener();
    setupTagFragmentListener();
}
 
开发者ID:theScrabi,项目名称:OCBookmarks,代码行数:10,代码来源:MainActivity.java

示例6: initFragments

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void initFragments(Bundle savedInstanceState) {
    FragmentManager fm = getChildFragmentManager();
    if (savedInstanceState == null) {
        mTimelineFragment = TimelineFragment.newInstance();
        mInfoFragment = InfoReadFragment.newInstance();
        mFavoritesFragment = FavoritesFragment.newInstance();
    } else {
        mTimelineFragment = (TimelineFragment) fm.getFragment(savedInstanceState, TimelineFragment.class.getSimpleName());
        mFavoritesFragment = (FavoritesFragment) fm.getFragment(savedInstanceState, FavoritesFragment.class.getSimpleName());
        mInfoFragment = (InfoReadFragment) fm.getFragment(savedInstanceState, InfoReadFragment.class.getSimpleName());
    }

    if (!mTimelineFragment.isAdded()) {
        fm.beginTransaction()
                .add(R.id.container, mTimelineFragment, TimelineFragment.class.getSimpleName())
                .commit();
    }

    if (!mFavoritesFragment.isAdded()) {
        fm.beginTransaction()
                .add(R.id.container, mFavoritesFragment, FavoritesFragment.class.getSimpleName())
                .commit();

    }

    if (!mInfoFragment.isAdded()) {
        fm.beginTransaction()
                .add(R.id.container, mInfoFragment, InfoReadFragment.class.getSimpleName())
                .commit();
    }
}
 
开发者ID:SpeedPromise,项目名称:L-Assistant,代码行数:32,代码来源:ReadFragment.java

示例7: initFragments

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void initFragments(Bundle saveInstanceState){
    FragmentManager fm = getSupportFragmentManager();
    if(saveInstanceState == null){
        mReadFragment = ReadFragment.newInstance();
        mWeatherFragment = WeatherFragment.newInstance();
        mPassFragment = PassFragment.newInstance();
        mScheduleFragment = ScheduleFragment.newInstance();
        mInfoFragment = InfoFragment.newInstance();
    }else{
        mReadFragment = (ReadFragment) fm.getFragment(saveInstanceState, ReadFragment.class.getSimpleName());
        mWeatherFragment = (WeatherFragment) fm.getFragment(saveInstanceState, WeatherFragment.class.getSimpleName());
        mPassFragment = (PassFragment) fm.getFragment(saveInstanceState, PassFragment.class.getSimpleName());
        mScheduleFragment = (ScheduleFragment) fm.getFragment(saveInstanceState, ScheduleFragment.class.getSimpleName());
        mInfoFragment = (InfoFragment) fm.getFragment(saveInstanceState, InfoFragment.class.getSimpleName());
    }

    if(!mReadFragment.isAdded()){
        fm.beginTransaction()
                .add(R.id.main_fragment, mReadFragment, ReadFragment.class.getSimpleName())
                .commit();
    }

    if(!mWeatherFragment.isAdded()){
        fm.beginTransaction()
                .add(R.id.main_fragment, mWeatherFragment, WeatherFragment.class.getSimpleName())
                .commit();
    }

    if(!mPassFragment.isAdded()){
        fm.beginTransaction()
                .add(R.id.main_fragment, mPassFragment, PassFragment.class.getSimpleName())
                .commit();
    }

    if(!mScheduleFragment.isAdded()){
        fm.beginTransaction()
                .add(R.id.main_fragment, mScheduleFragment, ScheduleFragment.class.getSimpleName())
                .commit();
    }

    if(!mInfoFragment.isAdded()){
        fm.beginTransaction()
                .add(R.id.main_fragment, mInfoFragment, InfoFragment.class.getSimpleName())
                .commit();
    }
}
 
开发者ID:SpeedPromise,项目名称:L-Assistant,代码行数:47,代码来源:MainActivity.java


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