當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentTransaction類代碼示例

本文整理匯總了Java中android.app.FragmentTransaction的典型用法代碼示例。如果您正苦於以下問題:Java FragmentTransaction類的具體用法?Java FragmentTransaction怎麽用?Java FragmentTransaction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FragmentTransaction類屬於android.app包,在下文中一共展示了FragmentTransaction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initMap

import android.app.FragmentTransaction; //導入依賴的package包/類
private void initMap() {

        PlaceAutocompleteFragment autocompleteFragment = new PlaceAutocompleteFragment();
        CustomMapFragment         mapFragment          = new CustomMapFragment();
        autocompleteFragment.setOnPlaceSelectedListener(this);
        mapFragment.setParent(mBinding.scroll);
        mapFragment.getMapAsync(this);

        FragmentManager     manager     = getActivity().getFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(R.id.place_autocomplete_fragment, autocompleteFragment);
        transaction.add(R.id.google_map_fragment, mapFragment);
        transaction.commit();

        mMarkerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
        mCircleOptions = new CircleOptions().fillColor(Color.argb(97, 93, 185, 139)).strokeColor(Color.argb(200, 93, 185, 139));

    }
 
開發者ID:OldBigBuddha,項目名稱:AlarmWithL-T,代碼行數:19,代碼來源:SettingFragment.java

示例2: showDialog

import android.app.FragmentTransaction; //導入依賴的package包/類
public void showDialog(Bundle bundle) {
    final Activity activity = (Activity) context;
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    Fragment prev = activity.getFragmentManager().findFragmentByTag(fragmentTag);
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    newFragment = MyDialogFragment.newInstance(bundle);
    newFragment.setList(list);
    newFragment.setContext(context);
    newFragment.setListener(listener);
    newFragment.show(ft, fragmentTag);

}
 
開發者ID:icaynia,項目名稱:pracler,代碼行數:17,代碼來源:SelectPopup.java

示例3: onNavigationItemSelected

import android.app.FragmentTransaction; //導入依賴的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

示例4: onNavigationItemSelected

import android.app.FragmentTransaction; //導入依賴的package包/類
/**
 * Metodo encargado de la navegacion. Usa item.getTitle para manejar el caso de intentar
 * navegar hacia la tab en la que ya estamos
 * @param item
 * @return true si se marca la tab, false si no
 */
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    Fragment newFragment = null;
    if(!(tabActualTitle == item.getTitle())){
        tabActualTitle = item.getTitle();
        switch (item.getItemId()) {
            case R.id.action_sofa:
                newFragment = Sofa.newInstance();
                break;
            case R.id.action_torneo:
                newFragment = Torneo.newInstance();
                break;
            case R.id.action_mapas:
                newFragment = Mapas.newInstance();
                break;
        }
        FragmentTransaction transaction = context.getFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment, newFragment);
        transaction.addToBackStack(null);
        transaction.commit();
        return true;
    }else{
        return false;
    }
}
 
開發者ID:cyanide4all,項目名稱:MySmashCouch,代碼行數:32,代碼來源:CustomNavigationListener.java

示例5: showDetails

import android.app.FragmentTransaction; //導入依賴的package包/類
/**
 * Hide list, show details and instruct the details view to show the selected book.
 */
@Override
public void showDetails(Book book, Drawable thumb) {
  final FragmentManager fragmentManager = getFragmentManager();
  FragmentTransaction ft = fragmentManager.beginTransaction();
  BookDetailsFragment details = (BookDetailsFragment) fragmentManager.findFragmentById(R.id.book_details);

  if (book != null) {
    // If null passed, we only configure fragment transaction here.
    details.showDetails(book, thumb);
  }

  ft.show(details);
  ft.hide(fragmentManager.findFragmentById(R.id.book_list));
  ft.addToBackStack("details"); // Use the back button to return to the search list view.

  ft.commit();
}
 
開發者ID:andviane,項目名稱:google-books-android-viewer,代碼行數:21,代碼來源:BookListActivity.java

示例6: removeFragment

import android.app.FragmentTransaction; //導入依賴的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

示例7: hidePreFragment

import android.app.FragmentTransaction; //導入依賴的package包/類
private void hidePreFragment(FragmentTransaction transaction) {
    Log.d(TAG, "hidePreFragment: mCurrentPageTag = "+mCurrentPageTag);
    switch (mCurrentPageTag) {
        case HOME_PAGE_TAG:
            transaction.hide(mHomeFragment);
            mHomeBtn.setTextColor(textColor);
            break;

        case EXPLORE_PAGE_TAG:
            transaction.hide(mExploreFragment);
            mExploreBtn.setTextColor(textColor);
            break;

        case MINE_PAGE_TAG:
            transaction.hide(mMineFragment);
            mMineBtn.setTextColor(textColor);
            break;
    }
}
 
開發者ID:AndroidWJC,項目名稱:UnversityFinance,代碼行數:20,代碼來源:MainActivity.java

示例8: onCreate

import android.app.FragmentTransaction; //導入依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_question);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  QuestionActivityFragment mainActivityFragment =
      (QuestionActivityFragment) getFragmentManager().findFragmentById(R.id.content_question);

  if (mainActivityFragment == null) {
    mainActivityFragment = QuestionActivityFragment.newInstance();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.add(R.id.content_question, mainActivityFragment);
    transaction.commit();
  }

  RequestFactory requestFactory = new RequestFactory();
  TriviaSharedPreferences triviaSharedPreferences = new TriviaSharedPreferences(
      PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
  int amount = getIntent().getIntExtra(AMOUNT, DEFAULT_AMOUNT_OF_QUESTIONS);
  String categoryId = getIntent().getStringExtra(CATEGORY_ID);
  String difficulty = getIntent().getStringExtra(DIFFICULTY);
  String questionType = getIntent().getStringExtra(GAME_TYPE);

  new QuestionPresenter(mainActivityFragment, requestFactory, triviaSharedPreferences, amount,
      categoryId, difficulty, questionType);
}
 
開發者ID:dfloureiro,項目名稱:opentrivia,代碼行數:28,代碼來源:QuestionActivity.java

示例9: reloadFragment

import android.app.FragmentTransaction; //導入依賴的package包/類
public static void reloadFragment(FragmentManager fragmentManager, Fragment fragment) {
		if (fragment != null){
			FragmentTransaction ft = fragmentManager.beginTransaction();
//			ft.setTransition(-1);
	//		ft.replace(containViewId, fragment);
			ft.detach(fragment);
			ft.attach(fragment);
			ft.commitAllowingStateLoss();
		}
	}
 
開發者ID:WowWeeLabs,項目名稱:CHIP-Android-SDK,代碼行數:11,代碼來源:FragmentHelper.java

示例10: goToRegister

import android.app.FragmentTransaction; //導入依賴的package包/類
private void goToRegister(){

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        RegisterFragment fragment = new RegisterFragment();
        ft.replace(R.id.fragmentFrame,fragment,RegisterFragment.TAG);
        ft.commit();
    }
 
開發者ID:EdwardAlexis,項目名稱:Sistema-de-Comercializacion-Negocios-Jhordan,代碼行數:8,代碼來源:LoginFragment.java

示例11: showUserFragment

import android.app.FragmentTransaction; //導入依賴的package包/類
private void showUserFragment(User user){
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag(USER_FRAGMENT_LABEL);
    if(prev != null){
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    UserFragment newFragment = UserFragment.newInstance(user);
    newFragment.show(ft, USER_FRAGMENT_LABEL);
}
 
開發者ID:Bartout-Team,項目名稱:Bartout,代碼行數:11,代碼來源:BartourActivity.java

示例12: changeFragment

import android.app.FragmentTransaction; //導入依賴的package包/類
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	FragmentManager fm = getFragmentManager();
	FragmentTransaction transaction = fm.beginTransaction();

	/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
		if (newFragmentType.isRightOf(currentFragment)) {
			transaction.setCustomAnimations(R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left,
					R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right);
		} else {
			transaction.setCustomAnimations(R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right,
					R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left);
		}
	}*/

	if (newFragmentType != FragmentsAvailable.DIALER
			&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
			&& newFragmentType != FragmentsAvailable.CHAT_LIST
			&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
		transaction.addToBackStack(newFragmentType.toString());
	} else {
		while (fm.getBackStackEntryCount() > 0) {
			fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
		}
	}

	transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
	transaction.commitAllowingStateLoss();
	fm.executePendingTransactions();

	currentFragment = newFragmentType;
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:36,代碼來源:LinphoneActivity.java

示例13: onCreate

import android.app.FragmentTransaction; //導入依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Check NightMode On/Off
        mConfig = getSharedPreferences(getString(R.string.key_config), MODE_PRIVATE);
        boolean isNightMode = mConfig.getBoolean(getString(R.string.key_is_night_mode), false);
        if (isNightMode) {
            setTheme(R.style.DarkTheme);
        } else {
            setTheme(R.style.LightTheme);
        }

        checkPermission();

        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_new_create);  //Binding Layout
        initToolbar();

        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        mFragment = SettingFragment.newInstance();
        transaction.add(R.id.setting_fragment, mFragment);
        transaction.commit();

        mRealm = Realm.getDefaultInstance(); // Initialize Realm
//        Intent intent = getIntent();
//       if (intent.getStringExtra("data") != null) {
//            Bundle bundle = new Bundle();
//            bundle.putString("data", intent.getStringExtra("data"));
//            mFragment.setArguments(bundle);
//            if (intent.getStringExtra(getString(R.string.key_title)) != null) {
//                mFragment.setArguments(intent.getExtras());
//            }
//        }
    }
 
開發者ID:OldBigBuddha,項目名稱:AlarmWithL-T,代碼行數:35,代碼來源:FormActivity.java

示例14: detach

import android.app.FragmentTransaction; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void detach(Fragment fragment,
                   FragmentTransaction currTransaction) {
    currTransaction.detach(fragment);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:6,代碼來源:ArrayPagerAdapter.java

示例15: summitFragment

import android.app.FragmentTransaction; //導入依賴的package包/類
private void summitFragment(String mediaId) {
    BrowserFragment fragment = getFragment();

    if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) {
        fragment = BrowserFragment.newInstance(mediaId);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.container, fragment, FRAGMENT_TAG);
        // If this is not the top level media (root), we add it to the fragment back stack,
        // so that actionbar toggle and Back will work appropriately:
        if (mediaId != null) {
            transaction.addToBackStack(null);
        }
        transaction.commit();
    }
}
 
開發者ID:Jaysaw,項目名稱:NovaMusicPlayer,代碼行數:16,代碼來源:MainActivity.java


注:本文中的android.app.FragmentTransaction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。