本文整理汇总了Java中android.app.FragmentTransaction.show方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTransaction.show方法的具体用法?Java FragmentTransaction.show怎么用?Java FragmentTransaction.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.FragmentTransaction
的用法示例。
在下文中一共展示了FragmentTransaction.show方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toggleCallControlFragmentVisibility
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void toggleCallControlFragmentVisibility() {
if (!iceConnected || !callFragment.isAdded()) {
return;
}
// Show/hide call control fragment
callControlFragmentVisible = !callControlFragmentVisible;
FragmentTransaction ft = getFragmentManager().beginTransaction();
if (callControlFragmentVisible) {
ft.show(callFragment);
ft.show(hudFragment);
} else {
ft.hide(callFragment);
ft.hide(hudFragment);
}
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
}
示例2: toggleCallControlFragmentVisibility
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void toggleCallControlFragmentVisibility() {
if (!iceConnected || !callFragment.isAdded()) {
return;
}
// Show/hide call control fragment
callControlFragmentVisible = !callControlFragmentVisible;
FragmentTransaction ft = getFragmentManager().beginTransaction();
if (callControlFragmentVisible) {
ft.show(callFragment);
ft.show(hudFragment);
} else {
ft.hide(callFragment);
ft.hide(hudFragment);
}
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
}
示例3: 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();
}
示例4: switchFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchFragment(int index) {
if (index == mCurrentIndex) return;
Fragment fragment = mFragments.get(index);
FragmentTransaction transaction =
mFragmentManager
.beginTransaction()
.setCustomAnimations(R.animator.fragment_in, R.animator.fragment_out);
String indexString = String.valueOf(index);
Fragment targetFragment = mFragmentManager.findFragmentByTag(indexString);
if (mCurrentIndex != -1) {
// 不是首次启动
transaction.hide(mFragments.get(mCurrentIndex));
}
if (targetFragment == null) {
// 之前没有添加过
transaction.add(R.id.fl_content, fragment, indexString);
} else {
transaction.show(targetFragment);
}
transaction.commit();
mCurrentIndex = index;
}
示例5: showFragmentOne
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
* 根据tag显示viewId里的一个fragment,其他全部隐藏
*/
public void showFragmentOne(int containerViewId, String tag) {
FragmentTransaction transaction = getTransaction();
for (Fragment fragment : getFragmentList(containerViewId)) {
if (fragment.getTag().equals(tag)) {
transaction.show(fragment);
} else if (!fragment.isHidden()) {
transaction.hide(fragment);
}
}
transaction.commit();
}
示例6: show
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**使用本方法前必须先add*/
public void show(Fragment fragment){
if (currentFragment==fragment) {
return;//如果是当前fragment,则不重新show一遍了,无意义
}
FragmentTransaction ft = fm.beginTransaction();
for (Fragment f:fs) {
ft.hide(f);
}
ft.show(fragment);
ft.commit();
currentFragment = fragment;
}
示例7: showList
import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void showList() {
final FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.show(fragmentManager.findFragmentById(R.id.book_list));
ft.hide(fragmentManager.findFragmentById(R.id.book_details));
ft.commit();
}
示例8: showCamera
import android.app.FragmentTransaction; //导入方法依赖的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;
}
示例9: showFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void showFragment(String name) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
for (Fragment f : fragments.values()) {
fragmentTransaction.hide(f);
}
if (fragments.containsKey(name)) {
fragmentTransaction.show(fragments.get(name));
currentFragment = name;
}
fragmentTransaction.commit();
}
示例10: onItemClick
import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onItemClick(int i) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// 隐藏所有的Fragment
if (exploreFragment != null)
transaction.hide(exploreFragment);
if (homeFragment != null)
transaction.hide(homeFragment);
if (settingsFragment != null)
transaction.hide(settingsFragment);
// 显示被选中的Fragment
switch (i) {
case 0: // 动态
if (homeFragment == null) {
homeFragment = new HomeFragment();
transaction.add(R.id.container, homeFragment);
} else
transaction.show(homeFragment);
setTitle(R.string.dynamic);
break;
case 1: // 发现
if (exploreFragment == null) {
exploreFragment = new ExploreFragment();
transaction.add(R.id.container, exploreFragment);
} else
transaction.show(exploreFragment);
setTitle(R.string.explore);
break;
case 3:
if (settingsFragment == null) {
settingsFragment = new SettingsFragment();
transaction.add(R.id.container, settingsFragment);
} else
transaction.show(settingsFragment);
setTitle("设置");
}
transaction.commit();
}
示例11: showFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void showFragment(String tag) {
if (mCurrentPageTag.equals(tag)) {
Log.d(TAG, "showFragment: return");
return;
}
FragmentTransaction beginTransaction= mFragmentManager.beginTransaction();
hidePreFragment(beginTransaction);
switch (tag) {
case HOME_PAGE_TAG:
if (mHomeFragment == null) {
mHomeFragment = new HomeFragment();
beginTransaction.add(R.id.fragment_area, mHomeFragment, tag);
} else {
beginTransaction.show(mHomeFragment);
}
mActionBarTitle.setText(R.string.app_name);
mHomeBtn.setTextColor(focusTextColor);
break;
case EXPLORE_PAGE_TAG:
if (mExploreFragment == null) {
mExploreFragment = new ExploreFragment();
beginTransaction.add(R.id.fragment_area, mExploreFragment, tag);
} else {
beginTransaction.show(mExploreFragment);
}
mActionBarTitle.setText(R.string.bottom_bar_explore);
mExploreBtn.setTextColor(focusTextColor);
break;
case MINE_PAGE_TAG:
if (mMineFragment == null) {
mMineFragment = new MineFragment();
beginTransaction.add(R.id.fragment_area, mMineFragment, tag);
} else {
beginTransaction.show(mMineFragment);
}
mActionBarTitle.setText(R.string.bottom_bar_mine);
mMineBtn.setTextColor(focusTextColor);
break;
}
mCurrentPageTag = tag;
beginTransaction.addToBackStack(tag);
beginTransaction.commit();
}