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


Java FragmentTransaction.add方法代码示例

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


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

示例1: onCreate

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

    if (savedInstanceState == null) {
        Fragment preferenceFragment = new BluetoothFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.pref_container, preferenceFragment);
        ft.commit();
    }

    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    registerReceiver(new Service(), filter);
}
 
开发者ID:Eun,项目名称:StartBluetooth,代码行数:16,代码来源:SettingsActivity.java

示例2: switchFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchFragment(NavButton oldNavButton, NavButton selectNav) {
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    if (oldNavButton != null) {
        if (oldNavButton.getFragment() != null) {
            transaction.detach(oldNavButton.getFragment());
        }
    }
    if (selectNav != null) {
        if (selectNav.getFragment() != null) {
            transaction.attach(selectNav.getFragment());
        } else {
            // Fragment.instantiate工具方法,再也不用自己newInstance().
            Fragment fragment = Fragment.instantiate(mContext, selectNav.getClx().getName(), null);
            transaction.add(mContainerId, fragment, selectNav.getNavBtnTag());
            selectNav.setFragment(fragment);
        }
    }
    transaction.commit();
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:20,代码来源:NavFragment.java

示例3: onShareDialogShow

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void onShareDialogShow(String jsonString) {
    FragmentManager fm = getSupportFragmentManager();
    if (fm != null) {
        FragmentTransaction ft = fm.beginTransaction();
        if (this.mShareProtocol == null) {
            LeResponseMessage response = LeMessageManager.getInstance().dispatchMessage(new LeMessage(LeMessageIds.MSG_SHARE_WEBVIEW_INIT, new OnWebViewRefreshListener() {
                public void onRefresh() {
                    LetvBaseWebViewActivity.this.refresh();
                }
            }));
            if (LeResponseMessage.checkResponseMessageValidity(response, WebViewShareProtocol.class)) {
                this.mShareProtocol = (WebViewShareProtocol) response.getData();
            }
        } else {
            ft.remove(this.mShareProtocol.getFragment());
        }
        if (this.mShareProtocol != null) {
            this.mShareProtocol.setDefaultShareText(this.mShareDefaultTitle, this.mShareDefaultDesc, getBaseUrl(), this.mShareDefaultIcon, this.baseUrl);
            ft.add(this.mShareProtocol.getFragment(), "shareDialog");
            this.mShareProtocol.setIsLoadComplete(this.loadFinish);
            this.mShareProtocol.notifyShareLayout();
        }
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:LetvBaseWebViewActivity.java

示例4: switchFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchFragment() {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.hide(mFragments[mCurrentTabIndex]);
    if (mFragments[mIndex].isAdded()){
        transaction.add(R.id.container, mFragments[mIndex]);
    }
    transaction.show(mFragments[mIndex]);
    mCurrentTabIndex = mIndex;
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:10,代码来源:MainActivity.java

示例5: addFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void addFragment(int[] layout, Fragment[] fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    for (int i = 0; i < layout.length; i++) {
        transaction.add(layout[i], fragment[i]);
    }
    transaction.commit();
}
 
开发者ID:Yuanhongliang,项目名称:HLOLI,代码行数:8,代码来源:BaseFragmentActivity.java

示例6: enterFragment2

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void enterFragment2(Conversation.ConversationType mConversationType, String mTargetId) {

        ConversationFragment fragment = new ConversationFragment();

        Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName).buildUpon()
                  .appendPath("conversation").appendPath(mConversationType.getName().toLowerCase())
                  .appendQueryParameter("targetId", mTargetId).build();

        fragment.setUri(uri);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.temp2, fragment);
        transaction.commit();
    }
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:14,代码来源:DoubleChatRoomActivity.java

示例7: show

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public BaseNiceDialog show(FragmentManager manager) {
    FragmentTransaction ft = manager.beginTransaction();
    if (this.isAdded()) {
        ft.remove(this).commit();
    }
    ft.add(this, String.valueOf(System.currentTimeMillis()));
    ft.commitAllowingStateLoss();
    return this;
}
 
开发者ID:Othershe,项目名称:NiceDialog,代码行数:10,代码来源:BaseNiceDialog.java

示例8: addFilePreviewerFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void addFilePreviewerFragment(Bundle savedInstance) {
    if (savedInstance == null) {
        filePreviewerFragment = FilePreviewerFragment.newInstance(savedInstance);
        FrameLayout fl = (FrameLayout) findViewById(R.id.filepreviewer_container);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(fl.getId(), filePreviewerFragment, FRAGMENT_FILE_PREVIEWER);
        ft.commit();
    } else {
        filePreviewerFragment = (FilePreviewerFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_FILE_PREVIEWER);
    }
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:12,代码来源:EditorActivity.java

示例9: setSelectFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void setSelectFragment(String search) {
    FragmentManager manager = view.getMainActivity().getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    if (search == null) {
        collectionFragment = manager.findFragmentByTag(TYPE_COLLECTION_TAG);
        hideFragment(transaction);
        if (null == collectionFragment) {
            collectionFragment = CollectionFragment.newInstance();
            transaction.add(R.id.fragment, collectionFragment, TYPE_COLLECTION_TAG);
        } else {
            transaction.show(collectionFragment);
        }
    } else {
        view.setToolBar();
        listFragment = manager.findFragmentByTag(TYPE_LIST_TAG);
        hideFragment(transaction);
        if (null == listFragment) {
            listFragment = TabFragment.newInstance(search);
            transaction.add(R.id.fragment, listFragment, TYPE_LIST_TAG);
        } else {
            if (!TextUtils.equals(search, TYPE_LIST_TAG)) {
                RxBus.getInstance().post(ApiConfig.BUS, search);
            }
            transaction.show(listFragment);
        }
    }
    transaction.commit();
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:29,代码来源:MainPresenterImpl.java

示例10: freshUI

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void freshUI(){
	FragmentManager fragmentManager = getSupportFragmentManager();
	FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

	Fragment fragment = fragmentManager.findFragmentByTag(FreshNewsPostsFragment.TAG);
	if(fragment == null){
		fragment = new FreshNewsPostsFragment();
		fragmentTransaction.add(R.id.container,fragment,FreshNewsPostsFragment.TAG);
	}else{
		fragmentTransaction.attach(fragment);
	}

	fragmentTransaction.commit();
}
 
开发者ID:Gookler,项目名称:RxJanDan,代码行数:15,代码来源:NavigationDrawerActivity.java

示例11: showTipDialog

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void showTipDialog(String code, String msg, PayTipsDialogFragment.OnDialogConfirmClickCallback callback) {
    PayTipsDialogFragment dialog = PayTipsDialogFragment.newInstance(code, msg);
    dialog.setCallback(callback);
    if (getActivity() != null) {
        FragmentTransaction ft = getMyFragmentManager(getActivity()).beginTransaction();
        ft.add(dialog, RPConstant.RP_TIP_DIALOG_TAG);
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:YunzhanghuOpen,项目名称:redpacketui-open,代码行数:10,代码来源:ReceivedRecordFragment.java

示例12: addFragmentToActivity

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *
 */
public static void addFragmentToActivity (@NonNull FragmentManager fragmentManager,
                                          @NonNull Fragment fragment, int frameId) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:12,代码来源:ActivityUtils.java

示例13: changeFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * Shows fragment at position and detaches previous fragment if exists. If fragment is found in
 * fragment manager, it is reattached else added.
 *
 * @param position
 * @return fragment at position
 */
public Fragment changeFragment(int position) {
    String tag = makeFragmentName(container.getId(), getItemId(position));
    FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();

    /*
      If fragment manager doesn't have an instance of the fragment, get an instance
      and add it to the transaction. Else, attach the instance to transaction.
     */
    Fragment fragment = mFragmentManager.findFragmentByTag(tag);
    if (fragment == null) {
        fragment = getItem(position);
        fragmentTransaction.add(container.getId(), fragment, tag);
    } else {
        fragmentTransaction.attach(fragment);
    }

    // Detach existing primary fragment
    Fragment curFrag = mFragmentManager.getPrimaryNavigationFragment();
    if (curFrag != null) {
        fragmentTransaction.detach(curFrag);
    }

    // Set fragment as primary navigator for child manager back stack to be handled by system
    fragmentTransaction.setPrimaryNavigationFragment(fragment);
    fragmentTransaction.setReorderingAllowed(true);
    fragmentTransaction.commitNowAllowingStateLoss();

    return fragment;
}
 
开发者ID:okaybroda,项目名称:FragmentStateManager,代码行数:37,代码来源:FragmentStateManager.java

示例14: switchFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchFragment(int lastIndex, int index) {
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    transaction.hide(mRxFragments[lastIndex]);
    if (!mRxFragments[index].isAdded()) {
        transaction.add(R.id.container, mRxFragments[index]);
    }
    transaction.show(mRxFragments[index]).commitAllowingStateLoss();
}
 
开发者ID:alphater,项目名称:garras,代码行数:9,代码来源:NavigationFragment.java

示例15: switchPanelFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void switchPanelFragment(BaseEditFragment baseEditFragment) {
    if (baseEditFragment != mMainMenuFragment && baseEditFragment != mHollowFragment) {
        undoButton.setVisibility(View.GONE);
    }
    FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
    fragmentTransaction.remove(mCurrentPanelFragment);
    fragmentTransaction.add(R.id.edit_panel_container, baseEditFragment);
    mCurrentPanelFragment = baseEditFragment;
    fragmentTransaction.commit();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:11,代码来源:EditImageActivity.java


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