当前位置: 首页>>代码示例>>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;未经允许,请勿转载。