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


Java FragmentTransaction.commit方法代碼示例

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


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

示例1: initCitySelect

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void initCitySelect(){
    citySelectFragment = CitySelectFragment.newInstance(new CitySelectFragment.OnSelectCity() {
        @Override
        public void onSelectCity(String disCode) {
            pullToRefreshLayout.showView(ViewStatus.LOADING_STATUS);

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    list.clear();
                    getData();
                    pullToRefreshLayout.showView(ViewStatus.CONTENT_STATUS);
                    deviceAdapter.notifyDataSetChanged();
                }
            }, 2000);
        }
    });
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.city_fragment_container, citySelectFragment);
    ft.commit();
}
 
開發者ID:ruiqiao2017,項目名稱:Renrentou,代碼行數:23,代碼來源:DeviceHotListActivityDeprecated.java

示例2: initFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void initFragment(){
    homeMyFragment = HomeMyFragment.newInstance();
    homeMyFragment.setOnRefresh(new HomeMyFragment.OnRefresh() {
        @Override
        public void success() {
            pullToRefreshLayout.finishRefresh();
        }

        @Override
        public void error() {
            pullToRefreshLayout.finishRefresh();
            showToast("加載失敗,請重試");
        }
    });
    FragmentManager fm = getChildFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.home_fragment_container, homeMyFragment);
    ft.commit();
}
 
開發者ID:ruiqiao2017,項目名稱:Renrentou,代碼行數:20,代碼來源:HomeFragment.java

示例3: transitToFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
void transitToFragment(Fragment next) {
  setUIPaused(false);
  InputMethodManager imm = (InputMethodManager) getSystemService(
      Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(mainLayout.getWindowToken(),
      InputMethodManager.HIDE_NOT_ALWAYS);

  FragmentManager manager = getSupportFragmentManager();
  FragmentTransaction transaction = manager.beginTransaction();
  transaction
      .setCustomAnimations(R.anim.config_in, android.R.anim.fade_out, android.R.anim.fade_in,
          R.anim.config_out2);
  transaction.replace(R.id.container, next);
  transaction.addToBackStack(null);
  transaction.commit();
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:17,代碼來源:MainActivity.java

示例4: addTab

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) {
    tabSpec.setContent(new DummyTabFactory(mContext));
    String tag = tabSpec.getTag();

    TabInfo info = new TabInfo(tag, clss, args);

    if (mAttached) {
        // If we are already attached to the window, then check to make
        // sure this tab's fragment is inactive if it exists. This shouldn't
        // normally happen.
        info.fragment = mFragmentManager.findFragmentByTag(tag);
        if (info.fragment != null && !info.fragment.isDetached()) {
            FragmentTransaction ft = mFragmentManager.beginTransaction();
            //				ft.detach(info.fragment);
            ft.hide(info.fragment);
            ft.commit();
        }
    }

    mTabs.add(info);
    addTab(tabSpec);
}
 
開發者ID:gaolhjy,項目名稱:cniao5,代碼行數:23,代碼來源:FragmentTabHost.java

示例5: showUrl

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public void showUrl(final String url, boolean popBackStack, String titleId)
{
	if (popBackStack) {
		popBackStackFull();
	}
    
	FragmentTransaction ft;
	
    
    ft = fm.beginTransaction();
    
    final Fragment fragment = new RMBTHelpFragment();        
    final Bundle args = new Bundle();
        
    args.putString(RMBTHelpFragment.ARG_URL, url);
    fragment.setArguments(args);
    ft.replace(R.id.fragment_content, fragment, titleId);
    ft.addToBackStack(titleId);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

    ft.commit();
    refreshActionBar(titleId);
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:24,代碼來源:RMBTMainActivity.java

示例6: onTabSelect

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * 切換tab頁
 * @param itemLayout
 */
public void onTabSelect(LinearLayout itemLayout) {
    int id = itemLayout.getId();
    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    hideFragments(manager, transaction);

    //下麵圖標顏色變化
    for (int i = 0; i < mLayouts.length; i++) {
        mLayouts[i].setSelected(false);
    }
    itemLayout.setSelected(true);

    if (id == R.id.layout_home) {
        selectedFragment(transaction, mHomeFragment, Main0Fragment.class, FRAGMENT_TAG_HOME);
    } else if (id == R.id.layout_categorize) {
        selectedFragment(transaction, mCategorizeFragment, Main1Fragment.class, FRAGMENT_TAG_Categorize);
    }  else if (id == R.id.layout_more) {
        selectedFragment(transaction, mPersonFragment, Main2Fragment.class, FRAGMENT_TAG_PERSON);
    }
    transaction.commit();
}
 
開發者ID:Break369,項目名稱:MyLife,代碼行數:26,代碼來源:MainActivity.java

示例7: onCreate

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    mUsername = getIntent().getStringExtra("username");
    if (savedInstanceState != null) {
        mUsername = savedInstanceState.getString("username");
    }

    FragmentManager fm = getSupportFragmentManager();
    ProfileFragment profileFragment = (ProfileFragment) fm.findFragmentByTag("profileFragment");
    if (profileFragment == null) {
        FragmentTransaction ft = fm.beginTransaction();
        profileFragment = ProfileFragment.newInstance();
        ft.add(android.R.id.content, profileFragment, "profileFragment");
        ft.commit();
    }

    // Create the presenter
    new ProfileFragmentPresenter(mUsername, profileFragment);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
}
 
開發者ID:Q115,項目名稱:Goalie_Android,代碼行數:27,代碼來源:ProfileActivity.java

示例8: addFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void addFragment(Fragment f, String tag, boolean isAddToBackStack) {
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.add(R.id.fragment_container, f);
    if (isAddToBackStack) {
        fragmentTransaction.addToBackStack(tag);
    }

    fragmentTransaction.commit();
}
 
開發者ID:BANKEX,項目名稱:smart-asset-iot-android-demo,代碼行數:11,代碼來源:BaseFragmentActivity.java

示例9: addFragmentToActivity

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public static void addFragmentToActivity (FragmentManager fragmentManager,
                                          Fragment fragment,
                                          int frameId,
                                          String tag) {

    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(frameId, fragment, tag);
    transaction.commit();
}
 
開發者ID:BracketCove,項目名稱:RoomDemo2017,代碼行數:10,代碼來源:BaseActivity.java

示例10: addFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public void addFragment(Fragment fragment, int fragmentPosition, String tag, boolean addToBackStack) {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
    ft.add(fragmentPosition, fragment, tag);
    // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    if (addToBackStack) {
        ft.addToBackStack(null);
    }
    ft.commit();
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:11,代碼來源:BaseActivity.java

示例11: enterFragment1

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void enterFragment1(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.temp1, fragment);
        transaction.commit();
    }
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:14,代碼來源:DoubleChatRoomActivity.java

示例12: showFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void showFragment(@NonNull MainFragment fragment, int oldTabIndex, int newTabIndex) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    if (newTabIndex > oldTabIndex)
        transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left);
    else if (newTabIndex < oldTabIndex)
        transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
    transaction.replace(R.id.content, fragment);
    transaction.commit();
}
 
開發者ID:schul-cloud,項目名稱:schulcloud-mobile-android,代碼行數:11,代碼來源:MainActivity.java

示例13: onCreate

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_barcode_fragment_test);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    BarcodeFragment bf = new BarcodeFragment();
    ft.add(R.id.container, bf);
    ft.commit();
}
 
開發者ID:ravi8x,項目名稱:Barcode-Reader,代碼行數:11,代碼來源:BarcodeFragmentTestActivity.java

示例14: addFragmentToActivity

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * The {@code fragment} is added to the container view with id {@code tag}. The operation is
 * performed by the {@code fragmentManager}.
 *
 */
public static void addFragmentToActivity (final FragmentManager fragmentManager,
    final Fragment fragment, final String tag) {
  checkNotNull(fragmentManager);
  checkNotNull(fragment);
  final FragmentTransaction transaction = fragmentManager.beginTransaction();
  transaction.add(fragment, tag);
  transaction.commit();
}
 
開發者ID:Esri,項目名稱:mapbook-android,代碼行數:14,代碼來源:ActivityUtils.java

示例15: onCreate

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        boolean isSupportHidden = savedInstanceState.getBoolean(STATE_SAVE_IS_HIDDEN);
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        if (isSupportHidden) {
            ft.hide(this);
        } else {
            ft.show(this);
        }
        ft.commit();
    }
    Log.d(TAG, "onCreate: ");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:BaseFragment.java


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