本文整理匯總了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();
}