Search in sources :

Example 91 with Fragment

use of android.support.v4.app.Fragment in project Android-skin-support by ximsfei.

the class MainActivity method configFragments.

private void configFragments() {
    List<Fragment> list = new ArrayList<>();
    list.add(new FirstFragment());
    list.add(new MiddleFragment());
    list.add(new LastFragment());
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    viewPager.setAdapter(new TabFragmentPagerAdapter(getSupportFragmentManager(), list));
    List<String> listTitle = new ArrayList<>();
    listTitle.add("系统组件");
    listTitle.add("自定义View");
    listTitle.add("第三方库控件");
    mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
    viewPager.setAdapter(mTabFragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : MiddleFragment(com.ximsfei.skindemo.tab.MiddleFragment) LastFragment(com.ximsfei.skindemo.tab.LastFragment) FirstFragment(com.ximsfei.skindemo.tab.FirstFragment) TabLayout(android.support.design.widget.TabLayout) ArrayList(java.util.ArrayList) TabFragmentPagerAdapter(com.ximsfei.skindemo.tab.TabFragmentPagerAdapter) LastFragment(com.ximsfei.skindemo.tab.LastFragment) FirstFragment(com.ximsfei.skindemo.tab.FirstFragment) Fragment(android.support.v4.app.Fragment) MiddleFragment(com.ximsfei.skindemo.tab.MiddleFragment) ViewPager(android.support.v4.view.ViewPager)

Example 92 with Fragment

use of android.support.v4.app.Fragment in project Android-skin-support by ximsfei.

the class MaterialDesignActivity method configFragments.

private void configFragments() {
    List<Fragment> list = new ArrayList<>();
    list.add(new MDFirstFragment());
    //        list.add(new MiddleFragment());
    //        list.add(new LastFragment());
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    List<String> listTitle = new ArrayList<>();
    listTitle.add("系统组件");
    //        listTitle.add("自定义View");
    //        listTitle.add("第三方库控件");
    mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
    viewPager.setAdapter(mTabFragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : TabLayout(android.support.design.widget.TabLayout) MDFirstFragment(com.ximsfei.skindemo.mdtab.MDFirstFragment) ArrayList(java.util.ArrayList) TabFragmentPagerAdapter(com.ximsfei.skindemo.tab.TabFragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) MDFirstFragment(com.ximsfei.skindemo.mdtab.MDFirstFragment) ViewPager(android.support.v4.view.ViewPager)

Example 93 with Fragment

use of android.support.v4.app.Fragment in project PocketHub by pockethub.

the class MainActivity method switchFragment.

@VisibleForTesting
void switchFragment(Fragment fragment, User organization) {
    if (organization != null) {
        Bundle args = new Bundle();
        args.putParcelable("org", organization);
        fragment.setArguments(args);
    }
    FragmentManager manager = getSupportFragmentManager();
    manager.beginTransaction().replace(R.id.container, fragment).commit();
    drawerLayout.closeDrawer(GravityCompat.START);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Bundle(android.os.Bundle) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 94 with Fragment

use of android.support.v4.app.Fragment in project PocketHub by pockethub.

the class PagerFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Fragment fragment = getFragment();
    if (fragment != null) {
        fragment.onCreateOptionsMenu(menu, getActivity().getMenuInflater());
    }
    super.onCreateOptionsMenu(menu, inflater);
}
Also used : Fragment(android.support.v4.app.Fragment)

Example 95 with Fragment

use of android.support.v4.app.Fragment in project carat by amplab.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CaratApplication.setMain(this);
    tracker = Tracker.getInstance();
    // track user clicks (taps)
    tracker.trackUser("caratstarted");
    if (!CaratApplication.isInternetAvailable()) {
        EnableInternetDialogFragment dialog = new EnableInternetDialogFragment();
        dialog.show(getSupportFragmentManager(), "dialog");
    }
    /*
		 * Activity.getWindow.requestFeature() should get invoked only before
		 * setContentView(), otherwise it will cause an app crash The progress
		 * bar doesn't get displayed when there is no update in progress
		 */
    getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    // Log.d(TAG, "about to set the layout");
    setContentView(R.layout.activity_main);
    ActionBar actionBar = getSupportActionBar();
    setTitleNormal();
    // read and load the preferences specified in our xml preference file
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    // Log.d(TAG, "about to initialize fragments");
    preInittializeFragments();
    // Log.d(TAG, "done with fragment initialization");
    /*
		 * Before using the field "fullVersion", first invoke setTitleNormal()
		 * or setFullVersion() to set this field
		 */
    mDrawerItems = getResources().getStringArray(R.array.drawer_items);
    List<Item> items = new ArrayList<Item>();
    //		items.add(new NavDrawerListHeader("Main"));
    items.add(new ListItem(mDrawerItems[0]));
    items.add(new ListItem(mDrawerItems[1]));
    items.add(new ListItem(mDrawerItems[2]));
    items.add(new ListItem(mDrawerItems[3]));
    items.add(new ListItem(mDrawerItems[4]));
    items.add(new NavDrawerListHeader(""));
    items.add(new ListItem(mDrawerItems[5]));
    items.add(new ListItem(mDrawerItems[6]));
    TextArrayAdapter adapter = new TextArrayAdapter(this, items);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(adapter);
    //		mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mDrawerItems));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description for accessibility */
    R.string.drawer_close) {

        /* "close drawer" description for accessibility */
        public void onDrawerClosed(View view) {
        //getSupportActionBar().setTitle(mTitle);
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mTitle);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    // Enable ActionBar app icon to behave as action to toggle navigation drawer
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    if (savedInstanceState == null) {
        selectItem(0);
    }
    setTitleNormal();
// Uncomment the following to enable listening on local port 8080:
/*
		 * try {
		 *  HelloServer h = new HelloServer();
		 * } catch (IOException e) {
		 *  e.printStackTrace(); 
		 * }
		 */
}
Also used : MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) EnableInternetDialogFragment(edu.berkeley.cs.amplab.carat.android.fragments.EnableInternetDialogFragment) ActionBar(android.support.v7.app.ActionBar)

Aggregations

Fragment (android.support.v4.app.Fragment)663 FragmentTransaction (android.support.v4.app.FragmentTransaction)233 Bundle (android.os.Bundle)149 View (android.view.View)140 FragmentManager (android.support.v4.app.FragmentManager)134 DialogFragment (android.support.v4.app.DialogFragment)80 TextView (android.widget.TextView)59 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)48 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)48 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)48 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)43 Intent (android.content.Intent)41 ViewPager (android.support.v4.view.ViewPager)38 FragmentActivity (android.support.v4.app.FragmentActivity)34 ImageView (android.widget.ImageView)32 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ArrayList (java.util.ArrayList)28 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ActionBar (android.support.v7.app.ActionBar)23