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;
            }
            
        }

    }

  • 相关阅读:
    MySql查看时间
    我的名人名言
    记录:今天架构让隔壁项目组使用MapDB,就好奇的百度了一下
    Hbase安装
    Hbase安装的坑: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing(2)
    Hbase安装的坑:java.lang.ClassNotFoundException: org.apache.htrace.SamplerBuilder(1)
    Kafka安装
    linux下zookeeper安装
    启动kafka生产者报错: WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
    org.postgresql.util.PSQLException: ������������: ��������� "runoobdba" ���������
  • 原文地址:https://www.cnblogs.com/3674-it/p/5550896.html
Copyright © 2011-2022 走看看