zoukankan      html  css  js  c++  java
  • Fragment的初步用法

    protected void replaceFragment(Fragment fragment , boolean init)
        {
            FragmentManager fragmentManager = this.getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            if(init)
            {
                fragmentTransaction.add(R.id.main_root, fragment);
            }
            else
            {
                fragmentTransaction.setCustomAnimations(R.anim.right_in    , R.anim.left_out , R.anim.left_in , R.anim.right_out);//添加切换进入和back键返回的动画
                fragmentTransaction.replace(R.id.main_root, fragment);//切换片段
                fragmentTransaction.addToBackStack(null);//并且加入stack中,以便返回
            }
            fragmentTransaction.commit();//提交
        }
    
    
    private void addFragment()
        {
            FragmentManager fragmentManager = this.getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    
            GalleryFlowFragment fragment = new GalleryFlowFragment();
    
            fragmentTransaction.add(R.id.main_root, fragment);//添加片段
    
            fragmentTransaction.commit();
        }
    
    
    public void popFragment()
        {
            FragmentManager fragmentManager = getSupportFragmentManager();                
            fragmentManager.popBackStack();// 返回前一个片段
        }

     相关链接:

    http://leybreeze.com/blog/?p=902

  • 相关阅读:
    51nod 1138 【数学-等差数列】
    hdoj3665【简单DFS】
    hdoj3664【DP】
    51nod1270 【dp】
    51nod 1069【思维】
    关于一些数学符号和概率的阐述;
    51nod 1428【贪心】
    51nod 1133【贪心】
    51nod1127【尺取】
    51nod1126【矩阵快速幂】
  • 原文地址:https://www.cnblogs.com/lipeil/p/2835687.html
Copyright © 2011-2022 走看看