本文整理汇总了Java中android.app.FragmentTransaction.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTransaction.isEmpty方法的具体用法?Java FragmentTransaction.isEmpty怎么用?Java FragmentTransaction.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.FragmentTransaction
的用法示例。
在下文中一共展示了FragmentTransaction.isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.address_book_content);
final FragmentManager fragmentManager = getFragmentManager();
walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);
final FragmentTransaction removal = fragmentManager.beginTransaction();
if (walletAddressesFragment == null)
walletAddressesFragment = new WalletAddressesFragment();
else
removal.remove(walletAddressesFragment);
if (sendingAddressesFragment == null)
sendingAddressesFragment = new SendingAddressesFragment();
else
removal.remove(sendingAddressesFragment);
if (!removal.isEmpty()) {
removal.commit();
fragmentManager.executePendingTransactions();
}
final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
if (pager != null) {
pager.setAdapter(
new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));
final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
R.string.address_book_list_sending_title);
pager.setOnPageChangeListener(pagerTabs);
final int position = 1;
pager.setCurrentItem(position);
pager.setPageMargin(2);
pager.setPageMarginDrawable(R.color.bg_less_bright);
pagerTabs.onPageSelected(position);
pagerTabs.onPageScrolled(position, 0, 0);
} else {
fragmentManager.beginTransaction().add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
.add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
}
updateFragments();
}