List of usage examples for android.support.v4.app FragmentManager findFragmentById
public abstract Fragment findFragmentById(int id);
From source file:com.facebook.samples.rps.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); setContentView(R.layout.main);/*from w w w. j av a 2 s . c o m*/ FragmentManager fm = getSupportFragmentManager(); fragments[RPS] = fm.findFragmentById(R.id.rps_fragment); fragments[SETTINGS] = fm.findFragmentById(R.id.settings_fragment); fragments[CONTENT] = fm.findFragmentById(R.id.content_fragment); FragmentTransaction transaction = fm.beginTransaction(); for (int i = 0; i < fragments.length; i++) { transaction.hide(fragments[i]); } transaction.commit(); hasNativeLink = handleNativeLink(); }
From source file:com.heneryh.aquanotes.ui.livestock.LivestockActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AnalyticsUtils.getInstance(this).trackPageView("/Livestock"); setContentView(R.layout.activity_livestock); // ActionBar bar = getActionBar(); // bar.setDisplayShowTitleEnabled(false); getActivityHelper().setupActionBar("Livestock", 0); final FragmentManager fm = getSupportFragmentManager(); ContentFragment frag = (ContentFragment) fm.findFragmentById(R.id.content_frag); if (frag != null) mDualFragments = true;//from ww w . ja v a2 s . c o m }
From source file:com.blandware.android.atleap.sample.ui.MainActivity.java
protected void setUpNavigationDrawer(Fragment fragment) { FragmentManager manager = getSupportFragmentManager(); if (fragment != null) { manager.beginTransaction().replace(R.id.navigation_drawer, fragment).commit(); } else {/*from ww w . j a v a 2 s. com*/ fragment = manager.findFragmentById(R.id.navigation_drawer); if (fragment != null) { manager.beginTransaction().remove(fragment).commit(); } //clean container too fragment = manager.findFragmentById(R.id.container); if (fragment != null) { manager.beginTransaction().remove(fragment).commit(); } } }
From source file:ch.corten.aha.worldclock.AddClockActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.add_city);/*from w w w .j a v a 2 s . c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); FragmentManager fm = getSupportFragmentManager(); // Create the list fragment and add it as our sole content. if (fm.findFragmentById(android.R.id.content) == null) { TimeZoneListFragment listFragment = new TimeZoneListFragment(); fm.beginTransaction().add(android.R.id.content, listFragment).commit(); } }
From source file:net.illusor.swipeplayer.activities.SwipeActivityTest.java
@Override public void setUp() throws Exception { super.setUp(); this.setActivityInitialTouchMode(true); this.activity = this.getActivity(); FragmentManager fragmentManager = this.activity.getSupportFragmentManager(); this.slidingMenu = (SlidingMenu) this.activity.findViewById(R.id.id_playlist_menu); this.audioControlFragment = (AudioControlFragment) fragmentManager.findFragmentById(R.id.id_audio_control); this.playlistOptionsFragment = (PlaylistOptionsFragment) fragmentManager .findFragmentById(R.id.id_fragment_options); this.viewPager = (ViewPager) this.activity.findViewById(R.id.id_swipe_view_pager); this.durationDisplayView = (DurationDisplayView) this.activity.findViewById(R.id.id_audio_durations); this.btnShuffle = (ToggleButton) this.activity.findViewById(R.id.id_playlist_shuffle); this.btnRepeat = (ToggleButton) this.activity.findViewById(R.id.id_playlist_repeat); }
From source file:com.afayear.android.client.activity.DualPaneActivity.java
public final Fragment getRightPaneFragment() { final FragmentManager fm = getSupportFragmentManager(); final Fragment right_pane_fragment = fm.findFragmentById(PANE_RIGHT); return right_pane_fragment; }
From source file:com.afayear.android.client.activity.DualPaneActivity.java
public final boolean isRightPaneUsed() { final FragmentManager fm = getSupportFragmentManager(); final Fragment right_pane_fragment = fm.findFragmentById(PANE_RIGHT); return right_pane_fragment != null && right_pane_fragment.isAdded(); }
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Show the list of directions//from www . j a v a2s. c om * @param directions List of DirectionManeuver items containing navigation directions */ public final void showDirections(final List<DirectionManeuver> directions) { final FragmentManager fm = getSupportFragmentManager(); RouteDirectionsFragment routeDirectionsFragment = (RouteDirectionsFragment) fm .findFragmentById(R.id.route_directions_container); if (routeDirectionsFragment == null) { routeDirectionsFragment = RouteDirectionsFragment.newInstance(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), routeDirectionsFragment, R.id.route_directions_container, getString(R.string.route_fragment)); } // Show the fragment final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.requestLayout(); // Hide the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(0, 0); layoutParams.setMargins(0, 0, 0, 0); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); routeDirectionsFragment.setRoutingDirections(directions); }
From source file:com.physphil.android.restaurantroulette.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.container); switch (position) { case 0:/*from w ww. j a v a 2 s . c om*/ mTitle = getString(R.string.title_restaurant_selector); saveMenuSelection(0); if (!(fragment instanceof RestaurantSelectorFragment)) { fragment = new RestaurantSelectorFragment(); } fm.beginTransaction().replace(R.id.container, fragment).commit(); break; case 1: mTitle = getString(R.string.title_restaurant_list); saveMenuSelection(1); newListFragment = false; if (!(fragment instanceof RestaurantListFragment)) { fragment = new RestaurantListFragment(); newListFragment = true; } fm.beginTransaction().replace(R.id.container, fragment).commit(); break; case 2: mTitle = getString(R.string.title_restaurant_history); saveMenuSelection(2); if (!(fragment instanceof HistoryListFragment)) { fragment = new HistoryListFragment(); } fm.beginTransaction().replace(R.id.container, fragment).commit(); break; } }
From source file:net.zorgblub.typhon.activity.ReadingActivity.java
@Override protected void onCreateTyphonActivity(Bundle savedInstanceState) { Typhon.getComponent().inject(this); FragmentManager supportFragmentManager = getSupportFragmentManager(); this.readingFragment = (ReadingFragment) supportFragmentManager.findFragmentById(R.id.fragment_reading); Class<? extends TyphonActivity> lastActivityClass = config.getLastActivity(); if (!config.isAlwaysOpenLastBook() && lastActivityClass != null && lastActivityClass != ReadingActivity.class && getIntent().getData() == null) { Intent intent = new Intent(this, lastActivityClass); startActivity(intent);//from www . j a v a2s.co m finish(); } }