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


Java FragmentManager.findFragmentById方法代码示例

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


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

示例1: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());//在Application的onCreate()不行,必须在activity的onCreate()中
    setContentView(R.layout.activity_main);
    Log.d("gaolei", "MainActivity---------onCreate---------------");
    setStatusBar();
    initMap();
    initView();
    isServiceLive = Utils.isServiceWork(this, "com.biubike.service.RouteService");
    if (isServiceLive)
        beginService();

    FragmentManager fm = getSupportFragmentManager();
    mMenuFragment = (LeftMenuFragment) fm.findFragmentById(R.id.id_container_menu);
    mLeftDrawerLayout.setOnMenuSlideListener(this);

    if (mMenuFragment == null) {
        fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment = new LeftMenuFragment()).commit();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:MainActivity.java

示例2: onCreate

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

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    //若获取的fragment已存在队列中,Fragment就直接返回它
    if (null == fragment) {
        //创建一个新的fragment事务,加入一个添加操作,然后提交该事务
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment)//param1是容器视图资源ID,param2是新创建的crimeFragment
                .commit();
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:18,代码来源:SingleFragmentActivity.java

示例3: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_capture_claim);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton attach = (FloatingActionButton) findViewById(R.id.attach);
    attach.setOnClickListener(this);

    selectedDate = (DatePickerLayout) findViewById(R.id.date);

    description = (EditText) findViewById(R.id.description);
    amount = (EditText) findViewById(R.id.amount);
    selectedDate = (DatePickerLayout) findViewById(R.id.date);

    final FragmentManager fragmentManager = getSupportFragmentManager();
    attachments = (AttachmentPagerFragment) fragmentManager.findFragmentById(R.id.attachments);
    categories = (CategoryPickerFragment) fragmentManager.findFragmentById(R.id.categories);

    if (savedInstanceState != null) {
        claimItem = savedInstanceState.getParcelable(KEY_CLAIM_ITEM);
    } else if (getIntent().hasExtra(EXTRA_CLAIM_ITEM)) {
        claimItem = getIntent().getParcelableExtra(EXTRA_CLAIM_ITEM);
    }

    if (claimItem == null) {
        claimItem = new ClaimItem();
    } else {
        description.setText(claimItem.getDescription());
        amount.setText(String.format("%f", claimItem.getAmount()));
        selectedDate.setDate(claimItem.getTimestamp());
    }

    attachments.setClaimItem(claimItem);
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:37,代码来源:CaptureClaimActivity.java

示例4: onCreate

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

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment)
                .commit();
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:16,代码来源:SingleFragmentActivity.java

示例5: onCreate

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

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(getFragmentContainerId());

    if (null == fragment) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(getFragmentContainerId(), fragment)
                .commit();
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:16,代码来源:SingleFragmentActivity.java

示例6: onCreate

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

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment)
                .commit();
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:16,代码来源:SingleFragmentActivity.java

示例7: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);
    ButterKnife.bind(this);
    initToolbar();

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);
    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction().add(R.id.fragment_container, fragment).commit();
    }
}
 
开发者ID:OlegKlimenko,项目名称:Plamber-Android,代码行数:15,代码来源:SingleFragmentActivity.java

示例8: onCreate

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

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction()
                .add(R.id.fragment_container, fragment, "RecipeListFragment")
                .commit();
    }
}
 
开发者ID:twisstosin,项目名称:UdacityBakingAndroid,代码行数:16,代码来源:BaseActivity.java

示例9: handleStateChange

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void handleStateChange(@NonNull StateChange stateChange, @NonNull Callback completionCallback) {
    singlePaneFragmentStateChanger.handleStateChange(stateChange);
    FragmentManager fragmentManager = FragmentManagerService.get(getContext());
    Fragment fragment = fragmentManager.findFragmentById(R.id.fragment_container);
    if(fragment != null && fragment.getView() != null && fragment.getView() instanceof IsMasterView) {
        ((IsMasterView) fragment.getView()).updateSelection(stateChange.<MasterDetailPath>topNewState());
    }
    completionCallback.stateChangeComplete();
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:11,代码来源:SinglePaneRoot.java

示例10: onCreate

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

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);
    if (fragment == null) {
        fragment = createFragment();
        fm.beginTransaction().add(R.id.fragment_container, fragment).commit();
    }
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:13,代码来源:SingleFragmentActivity.java

示例11: setFragment

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void setFragment() {
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.select_language_container);
    if (fragment == null) {
        fragment = new SelectLanguageFragamnt();
        fm.beginTransaction().replace(R.id.select_language_container, fragment).commit();
    }
}
 
开发者ID:OlegKlimenko,项目名称:Plamber-Android,代码行数:9,代码来源:SelectLanguageActivity.java

示例12: changeChildrenPresence

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void changeChildrenPresence(boolean isPresented) {
    FragmentManager childFragmentManager = getChildFragmentManager();
    FragmentTransaction fragmentTransaction = childFragmentManager.beginTransaction();

    Fragment child1 = childFragmentManager.findFragmentById(R.id.childContainer1);
    Fragment child2 = childFragmentManager.findFragmentById(R.id.childContainer2);

    if (isPresented) {
        // Add children if they aren't presented
        if (child1 == null) {
            fragmentTransaction.add(R.id.childContainer1, new ChildFragment());
        }
        if (child2 == null) {
            fragmentTransaction.add(R.id.childContainer2, new ChildFragment());
        }
    } else {
        // Remove children if they are presented
        if (child1 != null) {
            fragmentTransaction.remove(child1);
        }
        if (child2 != null) {
            fragmentTransaction.remove(child2);
        }
    }

    fragmentTransaction.commit();
}
 
开发者ID:Jeevuz,项目名称:Outlast,代码行数:28,代码来源:MainFragment.java

示例13: getNavigationFragment

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private NavigationFragment getNavigationFragment() {
    FragmentManager fm = getSupportFragmentManager();
    return (NavigationFragment) fm.findFragmentById(R.id.navigation_drawer);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:MainActivity.java


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