Search in sources :

Example 66 with Fragment

use of android.support.v4.app.Fragment in project ViewPagerIndicator by LuckyJayce.

the class FirstLayerFragment method onCreateViewLazy.

@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
    super.onCreateViewLazy(savedInstanceState);
    setContentView(R.layout.fragment_tabmain);
    Resources res = getResources();
    Bundle bundle = getArguments();
    tabName = bundle.getString(INTENT_STRING_TABNAME);
    index = bundle.getInt(INTENT_INT_INDEX);
    ViewPager viewPager = (ViewPager) findViewById(R.id.fragment_tabmain_viewPager);
    Indicator indicator = (Indicator) findViewById(R.id.fragment_tabmain_indicator);
    switch(index) {
        case 0:
            indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5));
            break;
        case 1:
            indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 0, Gravity.CENTENT_BACKGROUND));
            break;
        case 2:
            indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5, Gravity.TOP));
            break;
        case 3:
            indicator.setScrollBar(new LayoutBar(getApplicationContext(), R.layout.layout_slidebar, Gravity.CENTENT_BACKGROUND));
            break;
    }
    float unSelectSize = 16;
    float selectSize = unSelectSize * 1.2f;
    int selectColor = res.getColor(R.color.tab_top_text_2);
    int unSelectColor = res.getColor(R.color.tab_top_text_1);
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(selectColor, unSelectColor).setSize(selectSize, unSelectSize));
    viewPager.setOffscreenPageLimit(4);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    inflate = LayoutInflater.from(getApplicationContext());
    // 注意这里 的FragmentManager 是 getChildFragmentManager(); 因为是在Fragment里面
    // 而在activity里面用FragmentManager 是 getSupportFragmentManager()
    indicatorViewPager.setAdapter(new MyAdapter(getChildFragmentManager()));
    Log.d("cccc", "Fragment 将要创建View " + this);
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) Bundle(android.os.Bundle) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener) Resources(android.content.res.Resources) LayoutBar(com.shizhefei.view.indicator.slidebar.LayoutBar) IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) ViewPager(android.support.v4.view.ViewPager) Indicator(com.shizhefei.view.indicator.Indicator) ColorBar(com.shizhefei.view.indicator.slidebar.ColorBar)

Example 67 with Fragment

use of android.support.v4.app.Fragment in project 9GAG by Mixiaoxiao.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MxxSystemBarTintUtil.setSystemBarTintColor(this);
    SpannableString spannableString = new SpannableString("9GAG");
    String font = "LockScreen_Clock.ttf";
    spannableString.setSpan(new TypefaceSpan(font, Typeface.createFromAsset(getAssets(), font)), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    getActionBar().setTitle(spannableString);
    getActionBar().setDisplayShowHomeEnabled(false);
    setContentView(R.layout.activity_main);
    mViewPager = (ViewPager) findViewById(R.id.main_viewpager);
    //		scaleImageView = (MxxScaleImageView) findViewById(R.id.main_mxxScaleImageView1);
    mViewPager.setOffscreenPageLimit(3);
    mTabStrip = (MxxPagerSlidingTabStrip) findViewById(R.id.main_tab);
    ArrayList<Fragment> fragments = new ArrayList<Fragment>();
    fragments.add(new GagFragmentHot());
    fragments.add(new GagFragmentTrending());
    fragments.add(new GagFragmentFresh());
    mViewPager.setAdapter(new GagAdapter2(getSupportFragmentManager(), fragments, new String[] { "hot", "trending", "fresh" }));
    mTabStrip.setViewPager(mViewPager);
    initTint();
    mTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub
            if (((ViewGroup) tabLayout).getChildAt(0).getTranslationY() != 0) {
                ((ViewGroup) tabLayout).getChildAt(0).setTranslationY(0);
            }
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        // TODO Auto-generated method stub
        }
    });
    mImageFragment = (ImageFragment) getSupportFragmentManager().findFragmentById(R.id.main_image_fragment);
    mTabStrip.post(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            getSupportFragmentManager().beginTransaction().hide(mImageFragment).commit();
        }
    });
}
Also used : GagFragmentTrending(com.mixiaoxiao.ninegag.fragment.GagFragmentTrending) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) ImageFragment(com.mixiaoxiao.ninegag.fragment.ImageFragment) Fragment(android.support.v4.app.Fragment) GagFragment(com.mixiaoxiao.ninegag.fragment.GagFragment) ViewPager(android.support.v4.view.ViewPager) SpannableString(android.text.SpannableString) GagFragmentFresh(com.mixiaoxiao.ninegag.fragment.GagFragmentFresh) GagFragmentHot(com.mixiaoxiao.ninegag.fragment.GagFragmentHot) TypefaceSpan(com.mixiaoxiao.android.view.TypefaceSpan)

Example 68 with Fragment

use of android.support.v4.app.Fragment in project BoomMenu by Nightonke.

the class FragmentActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    assert viewPager != null;
    viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return new BMBFragment().position(position);
        }

        @Override
        public int getCount() {
            return 50;
        }
    });
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Example 69 with Fragment

use of android.support.v4.app.Fragment in project Signal-Android by WhisperSystems.

the class MmsPreferencesActivity method onCreate.

@Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Fragment fragment = new MmsPreferencesFragment();
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(android.R.id.content, fragment);
    fragmentTransaction.commit();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment)

Example 70 with Fragment

use of android.support.v4.app.Fragment in project Fragmentation by YoKeyword.

the class FragmentationDelegate method replaceTransaction.

/**
     * replace事务, 主要用于子Fragment之间的replace
     */
void replaceTransaction(FragmentManager fragmentManager, int containerId, SupportFragment to, boolean addToBack) {
    fragmentManager = checkFragmentManager(fragmentManager, null);
    if (fragmentManager == null)
        return;
    checkNotNull(to, "toFragment == null");
    bindContainerId(containerId, to);
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(containerId, to, to.getClass().getName());
    if (addToBack) {
        ft.addToBackStack(to.getClass().getName());
    }
    Bundle bundle = to.getArguments();
    bundle.putBoolean(FRAGMENTATION_ARG_IS_ROOT, true);
    supportCommit(fragmentManager, ft);
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Bundle(android.os.Bundle)

Aggregations

Fragment (android.support.v4.app.Fragment)617 FragmentTransaction (android.support.v4.app.FragmentTransaction)220 Bundle (android.os.Bundle)140 View (android.view.View)129 FragmentManager (android.support.v4.app.FragmentManager)115 DialogFragment (android.support.v4.app.DialogFragment)77 TextView (android.widget.TextView)55 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)39 ViewPager (android.support.v4.view.ViewPager)35 FragmentActivity (android.support.v4.app.FragmentActivity)34 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ImageView (android.widget.ImageView)27 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ArrayList (java.util.ArrayList)24 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21