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