本文整理汇总了Java中android.app.FragmentManager.findFragmentById方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.findFragmentById方法的具体用法?Java FragmentManager.findFragmentById怎么用?Java FragmentManager.findFragmentById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.findFragmentById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeFragment
import android.app.FragmentManager; //导入方法依赖的package包/类
public static void removeFragment(FragmentManager fragmentManager, int containViewId)
{
if(fragmentManager != null) {
Fragment fragment = fragmentManager.findFragmentById(containViewId);
if (fragment != null)
{
fragments.remove(fragment);
// TODO: Remove from backStackKeys
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.remove(fragment);
transaction.commitAllowingStateLoss();
}
}
else {
Log.e("FragmentHelper", "Fragment Manager = null");
}
}
示例2: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_us);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.menu_about);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
final FragmentManager fm = getFragmentManager();
final Fragment fragment = fm.findFragmentById(R.id.content);
if (fragment == null) {
fm.beginTransaction()
.replace(R.id.content, new AboutFragment())
.commit();
}
}
示例3: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
((QuranApplication) getApplication()).refreshLocale(this, false);
super.onCreate(savedInstanceState);
setContentView(R.layout.preferences);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.menu_settings);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
AudioManagerUtils.clearCache();
final FragmentManager fm = getFragmentManager();
final Fragment fragment = fm.findFragmentById(R.id.content);
if (fragment == null) {
fm.beginTransaction()
.replace(R.id.content, new QuranSettingsFragment())
.commit();
}
}
示例4: onTrimMemory
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onTrimMemory(int level) {
switch (level) {
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
Log.d(TAG, "Memory trimmed");
FragmentManager fragmentManager = getFragmentManager();
BookListFragment lf = (BookListFragment) fragmentManager.findFragmentById(R.id.book_list);
lf.adapter.getModel().lowMemory();
default:
break;
}
}
示例5: findFragments
import android.app.FragmentManager; //导入方法依赖的package包/类
/**
* Get references to existing fragments if the activity was restarted.
*/
private void findFragments() {
FragmentManager fragmentManager = getFragmentManager();
mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(
R.id.message_list_container);
mMessageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById(
R.id.message_view_container);
}
示例6: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.take_quiz_activity);
setTitle("Personality Quiz");
FragmentManager fm = getFragmentManager();
if (fm.findFragmentById(R.id.take_quiz_activity_content_layout) == null) {
Fragment fragment = QuestionsFragment.newInstance();
fm.beginTransaction()
.replace(R.id.take_quiz_activity_content_layout, fragment, fragment.getClass().getCanonicalName())
.commit();
}
}
示例7: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
FragmentManager fm = getFragmentManager();
Fragment fragment = fm.findFragmentById(R.id.fragment_container);
if (fragment == null)
fm.beginTransaction()
.replace(R.id.fragment_container, createFragment())
.commit();
}
示例8: onSaveInstanceState
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
FragmentManager fragmentManager = getFragmentManager();
BookListFragment lf = (BookListFragment) fragmentManager.findFragmentById(R.id.book_list);
outState.putBoolean("a.list", lf.isVisible());
}
示例9: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
FragmentManager fragmentManager = getFragmentManager();
Fragment fragment = fragmentManager.findFragmentById(R.id.fragmentContainer);
if (fragment == null){
fragment = createFragment();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(R.id.fragmentContainer, fragment);
transaction.commit();
}
onFragmentHasCreated((T) fragment,savedInstanceState);
}
示例10: initTabFragment
import android.app.FragmentManager; //导入方法依赖的package包/类
private void initTabFragment() {
FragmentManager fragmentManager = getFragmentManager();
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
tabFragment = (TabFragment) fragmentManager.findFragmentById(R.id.settings_fragment_land);
else
tabFragment = (TabFragment) fragmentManager.findFragmentById(R.id.settings_fragment);
tabFragment.initSeekBarValues((int) mPreviewPlanetMaker.getSize(), (int) mPreviewPlanetMaker.getScale(), (int) mPreviewPlanetMaker.getAngle());
}
示例11: setResultAndFinish
import android.app.FragmentManager; //导入方法依赖的package包/类
private void setResultAndFinish() {
Intent data = new Intent();
FragmentManager fm = getFragmentManager();
SettingsFragment f = (SettingsFragment) fm.findFragmentById(R.id.content);
data.putExtra("bufferChanged", f.getBufferChanged());
setResult(RESULT_OK, data);
finish();
}
示例12: setUpPresenter
import android.app.FragmentManager; //导入方法依赖的package包/类
private void setUpPresenter(PresenterFragmentImpl presenter, FragmentManager fragmentManager,
int updatableViewResId, Model model, QueryEnum[] queries,
UserActionEnum[] actions) {
UpdatableView ui = (UpdatableView) fragmentManager.findFragmentById(
updatableViewResId);
presenter.setModel(model);
presenter.setUpdatableView(ui);
presenter.setInitialQueriesToLoad(queries);
presenter.setValidUserActions(actions);
}
示例13: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResId());
FragmentManager manager = getFragmentManager();
Fragment fragment = manager.findFragmentById(R.id.fragmentContainer);
if (fragment == null) {
fragment = createFragment();
manager.beginTransaction()
.add(R.id.fragmentContainer, fragment)
.commit();
}
}
示例14: onCreateView
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getActivity().setTitle(getString(R.string.title_activity_maps));
view = inflater.inflate(R.layout.fragment_map, container, false);
FragmentManager fm = getFragmentManager();
boolean refresh = true;
if(savedInstanceState!=null)
refresh=false;
MapFragment fr = (MapFragment) fm.findFragmentById(R.id.map);
if(fr==null||refresh) {
fr = MapFragment.newInstance();
fm.beginTransaction().replace(R.id.map, fr).commit();
moveCamera = true;
} else {
moveCamera = false;
}
MobileAds.initialize(this.getActivity(), this.getResources().getString(R.string.unit_id));
AdView mAdView = (AdView) view.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
mAdView.loadAd(adRequest);
fr.getMapAsync(this);
return view;
}
示例15: onCreateView
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getActivity().setTitle(getString(R.string.title_activity_heat_maps));
view = inflater.inflate(R.layout.fragment_heat_map, container, false);
FragmentManager fm = getFragmentManager();
boolean refresh = true;
if(savedInstanceState!=null)
refresh=false;
MapFragment fr = (MapFragment) fm.findFragmentById(R.id.mapview);
if(fr==null||refresh) {
fr = MapFragment.newInstance();
fm.beginTransaction().replace(R.id.mapview, fr).commit();
moveCamera = true;
} else {
moveCamera = false;
}
MobileAds.initialize(this.getActivity(), this.getResources().getString(R.string.unit_id));
AdView mAdView = (AdView) view.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
mAdView.loadAd(adRequest);
fr.getMapAsync(this);
return view;
}