Search in sources :

Example 1 with Fragment

use of android.app.Fragment in project ActionBar-PullToRefresh by chrisbanes.

the class BaseSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Add the Sample Fragment if there is one
    Fragment sampleFragment = getSampleFragment();
    if (sampleFragment != null) {
        getFragmentManager().beginTransaction().replace(android.R.id.content, sampleFragment).commit();
    }
}
Also used : Fragment(android.app.Fragment)

Example 2 with Fragment

use of android.app.Fragment in project cw-omnibus by commonsguy.

the class MainActivity method showPreso.

private void showPreso(RouteInfo route) {
    if (inline.getVisibility() == View.VISIBLE) {
        inline.setVisibility(View.GONE);
        prose.setText(R.string.secondary);
        Fragment f = getFragmentManager().findFragmentById(R.id.preso);
        getFragmentManager().beginTransaction().remove(f).commit();
    }
    preso = buildPreso(route.getPresentationDisplay());
    preso.show(getFragmentManager(), "preso");
}
Also used : Fragment(android.app.Fragment)

Example 3 with Fragment

use of android.app.Fragment in project Depth-LIB-Android- by danielzeller.

the class RootActivity method goToFragment.

public void goToFragment(final Fragment newFragment) {
    getFragmentManager().beginTransaction().add(R.id.fragment_container, newFragment).commit();
    final Fragment removeFragment = currentFragment;
    currentFragment = newFragment;
    getWindow().getDecorView().postDelayed(new Runnable() {

        @Override
        public void run() {
            getFragmentManager().beginTransaction().remove(removeFragment).commit();
        }
    }, 2000);
}
Also used : Fragment(android.app.Fragment)

Example 4 with Fragment

use of android.app.Fragment 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 5 with Fragment

use of android.app.Fragment 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)

Aggregations

Fragment (android.app.Fragment)183 FragmentTransaction (android.app.FragmentTransaction)65 DialogFragment (android.app.DialogFragment)42 FragmentManager (android.app.FragmentManager)34 Bundle (android.os.Bundle)18 PreferenceFragment (android.support.v14.preference.PreferenceFragment)12 Intent (android.content.Intent)11 View (android.view.View)11 BizFragment (org.aisen.weibo.sina.ui.fragment.base.BizFragment)8 TextView (android.widget.TextView)6 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)6 Uri (android.net.Uri)5 PreferenceFragment (android.preference.PreferenceFragment)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 FrameLayout (android.widget.FrameLayout)3 Method (java.lang.reflect.Method)3 APagingFragment (org.aisen.android.ui.fragment.APagingFragment)3