• 团队冲刺06


    团队冲刺06

    今天遇到了很多的问题,有的通过查资料已经解决了,但是主要的还没有解决,太难了

    成果展示:

    package fragment;
    
    import android.app.Fragment;
    import android.os.Bundle;
    import android.support.annotation.Nullable;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    
    import com.example.animator.knowledge_circle.R;
    
    /**
     * Created by animator on 2020/4/5.
     */
    public class ConditionFragment extends Fragment {
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.fragment_by_condition,null);
            return view;
        }
    }
    package fragment;
    
    import android.app.Fragment;
    import android.app.FragmentManager;
    import android.app.FragmentTransaction;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.support.annotation.Nullable;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.LinearLayout;
    
    import com.example.animator.knowledge_circle.R;
    
    /**
     * Created by animator on 2020/4/5.
     */
    public class MessageFragment extends Fragment {
        LinearLayout l1,l2;
        View down1,down2;
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.fragment_message,null);
            Fragment fragment = new ConditionFragment();
            FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            fragmentTransaction.add(R.id.fragment_dy_condition, fragment);
            fragmentTransaction.commit();
            l1 = (LinearLayout) view.findViewById(R.id.message_l1);
            l2 = (LinearLayout) view.findViewById(R.id.message_l2);
            down1 = view.findViewById(R.id.message_down1);
            down2 = view.findViewById(R.id.message_down2);
            down1.setBackgroundColor(Color.parseColor("#f43a68"));
            l1.setOnClickListener(l);
            l2.setOnClickListener(l);
            return view;
        }
    
        View.OnClickListener l = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();//开启事务
                Fragment f = null;
                switch (view.getId()) {
                    case R.id.message_l1:
                        f = new ConditionFragment();
                        ft.replace(R.id.fragment_dy_condition, f);
                        ft.commit();
                        down1.setBackgroundColor(Color.parseColor("#f43a68"));
                        down2.setBackgroundColor(Color.parseColor("#f4f4f4"));
                        break;
                    case R.id.message_l2:
                        f = new InfoFragment();
                        ft.replace(R.id.fragment_dy_condition, f);
                        ft.commit();
                        down1.setBackgroundColor(Color.parseColor("#f4f4f4"));
                        down2.setBackgroundColor(Color.parseColor("#f43a68"));
                        break;
                }
            }
        };
    }

    截图:

  • 相关阅读:
    柔性数组
    2015阿里秋招当中一个算法题(经典)
    LAMP环境搭建
    JS和JQuery中的事件托付 学习笔记
    #17 Letter Combinations of a Phone Number
    码农生涯杂记_5
    【C++ Primer每日刷】之三 标准库 string 类型
    扎根本地连接未来 千米网的电商“红海”生存术
    poj 3356
    经验之谈—OAuth授权流程图
  • 原文地址:https://www.cnblogs.com/xueqiuxiang/p/12740703.html
Copyright © 2020-2023  润新知