本文整理匯總了Java中android.support.v4.app.Fragment.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.getId方法的具體用法?Java Fragment.getId怎麽用?Java Fragment.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.getId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hideShowFragment
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 先隱藏後顯示fragment
*
* @param hideFragment 需要隱藏的Fragment
* @param showFragment 需要顯示的Fragment
* @return 顯示的Fragment
*/
public static Fragment hideShowFragment(@NonNull final Fragment hideFragment,
@NonNull final Fragment showFragment) {
Args args = getArgs(hideFragment);
hideFragment.getId();
if (args != null) {
putArgs(hideFragment, new Args(args.id, true, args.isAddStack));
}
args = getArgs(showFragment);
if (args != null) {
putArgs(showFragment, new Args(args.id, false, args.isAddStack));
}
return operateFragment(showFragment.getFragmentManager(), hideFragment, showFragment, TYPE_SHOW_HIDE_FRAGMENT);
}
示例2: instantiateItem
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
if (currTransaction == null) {
currTransaction = fm.beginTransaction();
}
Fragment fragment = getExistingFragment(position);
if (fragment != null) {
if (fragment.getId() == container.getId()) {
retentionStrategy.attach(fragment, currTransaction);
} else {
fm.beginTransaction().remove(fragment).commit();
fm.executePendingTransactions();
currTransaction.add(container.getId(), fragment,
getFragmentTag(position));
}
} else {
fragment = createFragment(entries.get(position).getDescriptor());
currTransaction.add(container.getId(), fragment,
getFragmentTag(position));
}
if (fragment != currPrimaryItem) {
fragment.setMenuVisibility(false);
fragment.setUserVisibleHint(false);
}
return fragment;
}
示例3: showChart
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void showChart() {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(CHART_FRAGMENT);
if (fragment != null && !fragment.isDetached() && fragment.getId() != R.id.chart_dual) {
return;
}
openSinglePaneChartFragment();
}