Search in sources :

Example 6 with FragmentTransaction

use of android.app.FragmentTransaction in project SeriesGuide by UweTrottmann.

the class SeriesGuidePreferences method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(SeriesGuidePreferences.THEME);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    setupActionBar();
    if (savedInstanceState == null) {
        Fragment f = new SettingsFragment();
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.add(R.id.containerSettings, f);
        ft.commit();
        // open a sub settings screen if requested
        String settingsScreen = getIntent().getStringExtra(EXTRA_SETTINGS_SCREEN);
        if (settingsScreen != null) {
            switchToSettings(settingsScreen);
        }
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) PreferenceFragment(android.preference.PreferenceFragment)

Example 7 with FragmentTransaction

use of android.app.FragmentTransaction in project SeriesGuide by UweTrottmann.

the class ListWidgetConfigure method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // set a theme based on user preference
    setTheme(SeriesGuidePreferences.THEME);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_singlepane);
    setupActionBar();
    // if the user backs out, no widget gets added
    setResult(RESULT_CANCELED);
    // get given app widget id
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    // If they gave us an intent without the widget id, just bail.
    if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        finish();
        return;
    }
    if (savedInstanceState == null) {
        ListWidgetPreferenceFragment f = ListWidgetPreferenceFragment.newInstance(mAppWidgetId);
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.add(R.id.content_frame, f);
        ft.commit();
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Bundle(android.os.Bundle) Intent(android.content.Intent)

Example 8 with FragmentTransaction

use of android.app.FragmentTransaction in project android_frameworks_base by ParanoidAndroid.

the class BiDiTestActivity method onListItemClick.

private void onListItemClick(ListView lv, View v, int position, long id) {
    // Show the test
    Map<String, Object> map = (Map<String, Object>) lv.getItemAtPosition(position);
    int fragmentId = (Integer) map.get(KEY_FRAGMENT_ID);
    Fragment fragment = getFragmentManager().findFragmentById(fragmentId);
    if (fragment == null) {
        try {
            // Create an instance of the test
            Class<? extends Fragment> clazz = (Class<? extends Fragment>) map.get(KEY_CLASS);
            fragment = clazz.newInstance();
            // Replace the old test fragment with the new one
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.replace(R.id.testframe, fragment);
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            ft.commit();
        } catch (InstantiationException e) {
        } catch (IllegalAccessException e) {
        }
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) HashMap(java.util.HashMap) Map(java.util.Map) Fragment(android.app.Fragment)

Example 9 with FragmentTransaction

use of android.app.FragmentTransaction in project android_frameworks_base by ParanoidAndroid.

the class PreferenceActivity method startPreferencePanel.

/**
     * Start a new fragment containing a preference panel.  If the prefences
     * are being displayed in multi-pane mode, the given fragment class will
     * be instantiated and placed in the appropriate pane.  If running in
     * single-pane mode, a new activity will be launched in which to show the
     * fragment.
     * 
     * @param fragmentClass Full name of the class implementing the fragment.
     * @param args Any desired arguments to supply to the fragment.
     * @param titleRes Optional resource identifier of the title of this
     * fragment.
     * @param titleText Optional text of the title of this fragment.
     * @param resultTo Optional fragment that result data should be sent to.
     * If non-null, resultTo.onActivityResult() will be called when this
     * preference panel is done.  The launched panel must use
     * {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
     * @param resultRequestCode If resultTo is non-null, this is the caller's
     * request code to be received with the resut.
     */
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
    if (mSinglePane) {
        startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
    } else {
        Fragment f = Fragment.instantiate(this, fragmentClass, args);
        if (resultTo != null) {
            f.setTargetFragment(resultTo, resultRequestCode);
        }
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(com.android.internal.R.id.prefs, f);
        if (titleRes != 0) {
            transaction.setBreadCrumbTitle(titleRes);
        } else if (titleText != null) {
            transaction.setBreadCrumbTitle(titleText);
        }
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(BACK_STACK_PREFS);
        transaction.commitAllowingStateLoss();
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment)

Example 10 with FragmentTransaction

use of android.app.FragmentTransaction in project android_frameworks_base by ParanoidAndroid.

the class PreferenceActivity method startPreferenceFragment.

/**
     * Start a new fragment.
     *
     * @param fragment The fragment to start
     * @param push If true, the current fragment will be pushed onto the back stack.  If false,
     * the current fragment will be replaced.
     */
public void startPreferenceFragment(Fragment fragment, boolean push) {
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(com.android.internal.R.id.prefs, fragment);
    if (push) {
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(BACK_STACK_PREFS);
    } else {
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    }
    transaction.commitAllowingStateLoss();
}
Also used : FragmentTransaction(android.app.FragmentTransaction)

Aggregations

FragmentTransaction (android.app.FragmentTransaction)419 Fragment (android.app.Fragment)125 FragmentManager (android.app.FragmentManager)120 Bundle (android.os.Bundle)56 Test (org.junit.Test)36 FragmentActivity (android.support.v4.app.FragmentActivity)27 Intent (android.content.Intent)25 DialogFragment (android.app.DialogFragment)22 View (android.view.View)20 PreferenceFragment (android.support.v14.preference.PreferenceFragment)13 TextView (android.widget.TextView)12 MapCalibrationFragment (com.peterlaurence.trekadvisor.menu.mapcalibration.MapCalibrationFragment)8 MapImportFragment (com.peterlaurence.trekadvisor.menu.mapimport.MapImportFragment)8 MapListFragment (com.peterlaurence.trekadvisor.menu.maplist.MapListFragment)8 MapSettingsFragment (com.peterlaurence.trekadvisor.menu.maplist.MapSettingsFragment)8 MapViewFragment (com.peterlaurence.trekadvisor.menu.mapview.MapViewFragment)8 MarkerManageFragment (com.peterlaurence.trekadvisor.menu.mapview.components.markermanage.MarkerManageFragment)8 TracksManageFragment (com.peterlaurence.trekadvisor.menu.mapview.components.tracksmanage.TracksManageFragment)8 RecordFragment (com.peterlaurence.trekadvisor.menu.record.RecordFragment)8 Uri (android.net.Uri)7