本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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: ");
}