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