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


Java FragmentManager.beginTransaction方法代码示例

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


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

示例1: onNavigationItemSelected

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
        case R.id.navigation_home:
            FragmentManager manager = getFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.replace(R.id.content, ProjectFragment.newInstance()); // newInstance() is a static factory method.
            transaction.commit();
            return true;
        case R.id.navigation_dashboard:
            FragmentManager newsManager = getFragmentManager();
            FragmentTransaction transaction1 = newsManager.beginTransaction();
            transaction1.replace(R.id.content, OrgFragment.newInstance()); // newInstance() is a static factory method.
            transaction1.commit();
            return true;
        case R.id.navigation_notifications:
            FragmentManager projectManager = getFragmentManager();
            FragmentTransaction transaction2 = projectManager.beginTransaction();
            transaction2.replace(R.id.content, MapFragment.newInstance()); // newInstance() is a static factory method.
            transaction2.commit();
            return true;
    }
    return false;
}
 
开发者ID:techstar-cloud,项目名称:techstar-org,代码行数:25,代码来源:MainActivity.java

示例2: removeFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void removeFragment(FragmentManager fragmentManager, int containViewId)
{
	if(fragmentManager != null) {
		Fragment fragment = fragmentManager.findFragmentById(containViewId);
		if (fragment != null)
		{
			fragments.remove(fragment);
			
			// TODO: Remove from backStackKeys
			
			FragmentTransaction transaction = fragmentManager.beginTransaction();
			transaction.remove(fragment);
			transaction.commitAllowingStateLoss();
		}
	}
	else {
		Log.e("FragmentHelper", "Fragment Manager = null");
	}
}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:20,代码来源:FragmentHelper.java

示例3: initializeFragments

import android.app.FragmentManager; //导入方法依赖的package包/类
/**
 * Create fragment instances if necessary.
 *
 * @see #findFragments()
 */
private void initializeFragments() {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.addOnBackStackChangedListener(this);

    boolean hasMessageListFragment = (mMessageListFragment != null);

    if (!hasMessageListFragment) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mMessageListFragment = MessageListFragment.newInstance(mSearch, false,
                (QMail.isThreadedViewEnabled() && !mNoThreading));
        ft.add(R.id.message_list_container, mMessageListFragment);
        ft.commit();
    }

    // Check if the fragment wasn't restarted and has a MessageReference in the arguments. If
    // so, open the referenced message.
    if (!hasMessageListFragment && mMessageViewFragment == null &&
            mMessageReference != null) {
        openMessage(mMessageReference);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:27,代码来源:MessageList.java

示例4: onOptionsItemSelected

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        SettingFragment preference=new SettingFragment();
        try {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.container, preference);
            fragmentTransaction.addToBackStack(null); // 戻るボタンでreplace前に戻る
            fragmentTransaction.commit();
        } catch (Exception e) {
            SdLog.log(e);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:19,代码来源:AOdiaActivity.java

示例5: initView

import android.app.FragmentManager; //导入方法依赖的package包/类
private void initView() {
    FragmentManager fm = getFragmentManager();
    FragmentTransaction tx = fm.beginTransaction();
    FileFragment fragment = FileFragment.newInstance("文件");
    tx.add(R.id.framlayout, fragment,"ONE");
    tx.commit();

}
 
开发者ID:WeiMei-Tian,项目名称:FileBrowser,代码行数:9,代码来源:MainActivity.java

示例6: showCamera

import android.app.FragmentManager; //导入方法依赖的package包/类
private boolean showCamera(CallbackContext callbackContext) {
  if(this.hasView(callbackContext) == false){
    return true;
  }

  FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.show(fragment);
  fragmentTransaction.commit();

  callbackContext.success();
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:14,代码来源:CameraPreview.java

示例7: prepareSettings

import android.app.FragmentManager; //导入方法依赖的package包/类
private void prepareSettings() {
    String title, fragId;
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        title = bundle.getString("title");
        fragId = bundle.getString("frag_id");
    } else {
        title = getString(R.string.preference);
        fragId = "GeneralSettingsFragment";
    }

    TextView textView = (TextView) findViewById(R.id.settings_bar);
    textView.setText(title);

    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    if ("GeneralSettingsFragment".equals(fragId)) {
        fragmentTransaction.replace(R.id.preferences_fragment, new GeneralSettingsFragment());
    } else if ("CommentSettingsFragment".equals(fragId)) {
        fragmentTransaction.replace(R.id.preferences_fragment, new CommentSettingsFragment());
    }
    fragmentTransaction.commit();
}
 
开发者ID:KoreHuang,项目名称:WeChatLuckyMoney,代码行数:25,代码来源:SettingsActivity.java

示例8: setupTransaction

import android.app.FragmentManager; //导入方法依赖的package包/类
/**
 * Setup a base dialog fragment transaction. Handles the removing of a
 * previous fragment if it exists and adds itself to the backstack.
 *
 * @return FragmentTransaction
 */
private FragmentTransaction setupTransaction(Activity activity) {
    FragmentManager manager = activity.getFragmentManager();
    FragmentTransaction ft = manager.beginTransaction();
    Fragment prev = manager.findFragmentByTag("dialog");

    if (prev != null)
        ft.remove(prev);

    ft.addToBackStack(null);

    return ft;
}
 
开发者ID:linklux,项目名称:android-schedules,代码行数:19,代码来源:BaseDialogFragment.java

示例9: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MapPrefFragment settingsFragment = new MapPrefFragment();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(android.R.id.content, settingsFragment);
    fragmentTransaction.commit();
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:10,代码来源:MapPrefActivity.java

示例10: clearAllBackStackFragments

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void clearAllBackStackFragments(FragmentManager fragmentManager)
{
	FragmentTransaction ft = fragmentManager.beginTransaction();

    for (WeakReference<Fragment> ref : fragments) {
        Fragment fragment = ref.get();
        if (fragment != null) {
            ft.remove(fragment);
        }
    }
    fragments.clear();
    backStackKeys.clear();

    ft.commitAllowingStateLoss();
}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:16,代码来源:FragmentHelper.java

示例11: showChangeLogDialog

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void showChangeLogDialog(FragmentManager fragmentManager) {
    ChangelogDialog changelogDialog = new ChangelogDialog();
    FragmentTransaction ft = fragmentManager.beginTransaction();
    Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    changelogDialog.show(ft, "changelogdemo_dialog");
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:11,代码来源:ChangelogDialog.java

示例12: show

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void show(FragmentManager fm, ArrayList<DocumentInfo> docs, boolean deleteAfter) {
	final Bundle args = new Bundle();
	args.putParcelableArrayList(EXTRA_DOC_LIST, docs);
	args.putBoolean(EXTRA_DELETE_AFTER, deleteAfter);
	
	final MoveFragment fragment = new MoveFragment();
	fragment.setArguments(args);

	final FragmentTransaction ft = fm.beginTransaction();
	ft.replace(R.id.container_save, fragment, TAG);
	ft.commitAllowingStateLoss();
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:13,代码来源:MoveFragment.java

示例13: onCreate

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

	SettingsFragment settingsFragment = new SettingsFragment();
	FragmentManager fragmentManager = getFragmentManager();
	FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
	fragmentTransaction.replace(android.R.id.content, settingsFragment);
	fragmentTransaction.commit();
}
 
开发者ID:takyonxxx,项目名称:AndroidSdrRtlTuner,代码行数:11,代码来源:SettingsActivity.java

示例14: show

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void show(FragmentManager fm) {
    final PickFragment fragment = new PickFragment();

    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container_save, fragment, TAG);
    ft.commitAllowingStateLoss();
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:8,代码来源:PickFragment.java

示例15: onCreate

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


    mFragment = TableViewerFragment.newInstance("db3.db", "name");
    mFragment.setOnItemClicked(this);

    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();

    ft.add(R.id.flFragment, mFragment, "TAG").commit();
}
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:15,代码来源:MainDb3Activity.java


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