zoukankan      html  css  js  c++  java
  • Fragment事物

    public class MainActivity extends FragmentActivity implements OnClickListener{
     
        private ImageView sou;
        private List<Fragment> list;
        private ImageView shou;
        private ImageView pin;
        private ImageView gou;
        private ImageView geng;
        private TextView tv;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_main);
            
            sou = (ImageView)findViewById(R.id.sou);
            shou = (ImageView)findViewById(R.id.shou);
            pin = (ImageView)findViewById(R.id.pin);
            gou = (ImageView)findViewById(R.id.gou);
            geng = (ImageView)findViewById(R.id.geng);
            
            shou.setOnClickListener(this);
            sou.setOnClickListener(this);
            pin.setOnClickListener(this);
            gou.setOnClickListener(this);
            geng.setOnClickListener(this);
            
            FragmentManager fragmentManager = getSupportFragmentManager();
            
            getSupportFragmentManager().beginTransaction().replace(R.id.fragment,new Shou()).commit();
        }
        
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
            case R.id.shou:
                System.out.println("=============");
                shou.setBackground(getResources().getDrawable(R.drawable.bar_home_selected));
                sou.setBackground(getResources().getDrawable(R.drawable.bar_search_normal));
                pin.setBackground(getResources().getDrawable(R.drawable.bar_class_normal));
                gou.setBackground(getResources().getDrawable(R.drawable.bar_shopping_normal));
                geng.setBackground(getResources().getDrawable(R.drawable.bar_more_normal));
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment,new Shou()).commit();
                break;
            case R.id.sou:
                sou.setBackground(getResources().getDrawable(R.drawable.bar_search_selected));
                shou.setBackground(getResources().getDrawable(R.drawable.bar_home_normal));
                pin.setBackground(getResources().getDrawable(R.drawable.bar_class_normal));
                gou.setBackground(getResources().getDrawable(R.drawable.bar_shopping_normal));
                geng.setBackground(getResources().getDrawable(R.drawable.bar_more_normal));
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment,new Sou()).commit();
                break;
            case R.id.pin:
                pin.setBackground(getResources().getDrawable(R.drawable.bar_class_selected));
                shou.setBackground(getResources().getDrawable(R.drawable.bar_home_normal));
                sou.setBackground(getResources().getDrawable(R.drawable.bar_search_normal));
                gou.setBackground(getResources().getDrawable(R.drawable.bar_shopping_normal));
                geng.setBackground(getResources().getDrawable(R.drawable.bar_more_normal));
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment,new Pin()).commit();
                break;
            case R.id.gou:
                gou.setBackground(getResources().getDrawable(R.drawable.bar_shopping_selected));
                shou.setBackground(getResources().getDrawable(R.drawable.bar_home_normal));
                sou.setBackground(getResources().getDrawable(R.drawable.bar_search_normal));
                pin.setBackground(getResources().getDrawable(R.drawable.bar_class_normal));
                geng.setBackground(getResources().getDrawable(R.drawable.bar_more_normal));
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment,new Gou()).commit();
                break;
            case R.id.geng:
                geng.setBackground(getResources().getDrawable(R.drawable.bar_more_selected));
                shou.setBackground(getResources().getDrawable(R.drawable.bar_home_normal));
                sou.setBackground(getResources().getDrawable(R.drawable.bar_search_normal));
                pin.setBackground(getResources().getDrawable(R.drawable.bar_class_normal));
                gou.setBackground(getResources().getDrawable(R.drawable.bar_shopping_normal));
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment,new Geng()).commit();
                break;
            default:
                break;
            }
            
        }

    }

  • 相关阅读:
    第二阶段工作总结 07
    第二阶段工作总结 06
    学习进度条 第十三周
    第二阶段 工作总结 05
    小水王2
    第二冲刺阶段 工作总结 04
    第二冲刺阶段 工作总结 03
    第二冲刺阶段 工作总结 02
    第二冲刺阶段 工作总结 01
    学弟进度条 第十二周
  • 原文地址:https://www.cnblogs.com/3674-it/p/5550896.html
Copyright © 2011-2022 走看看