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