本文整理汇总了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();
}
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例13: getNavigationFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private NavigationFragment getNavigationFragment() {
FragmentManager fm = getSupportFragmentManager();
return (NavigationFragment) fm.findFragmentById(R.id.navigation_drawer);
}