zoukankan      html  css  js  c++  java
  • 第二阶段冲刺第六天

    package com.example.myapplicationgb;
    
    import android.database.Cursor;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    
    import androidx.annotation.Nullable;
    import androidx.fragment.app.Fragment;
    
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.List;
    
    import lecho.lib.hellocharts.model.PieChartData;
    import lecho.lib.hellocharts.model.SliceValue;
    import lecho.lib.hellocharts.view.PieChartView;
    
    public class siFragment extends Fragment {
        private String context;
        private TextView mTextView;
        private Button daka;
        private final String TAG="siFragment";
        int i=0;
        private TextView day;
        int year1,month1,day1;
        private DatabaseHelper mDatabaseHelper ;
        private List<CostBean> mCostBeanList;
    
        TextView zhichu_money;
        TextView yue_money;
        EditText jine;
        String jin;
        int all_1;
        Button queding;
        PieChartView pieChartView;
        int[] data={1,2,3,4};
        List<SliceValue> values = new ArrayList<>();
    
        public siFragment(String context){
            this.context = context;
        }
    
        public siFragment() {
    
        }
    
        @Override
        public void onActivityCreated(@Nullable Bundle savedInstanceState)  {
            super.onActivityCreated(savedInstanceState);
    
    
    
            //取本月
            Calendar calendar = Calendar.getInstance();
            year1 = calendar.get(Calendar.YEAR);
            month1 = calendar.get(Calendar.MONTH)+1;
            day1 = calendar.get(Calendar.DAY_OF_MONTH);
            String i= siFragment.this.month1+"月";
            Log.e("22",i);
            Cursor cursor =mDatabaseHelper.selectlist(i);
            if (cursor != null){
                while (cursor.moveToNext()){
                    CostBean costBean = new CostBean();
                    costBean.costTitle = cursor.getString(cursor.getColumnIndex("cost_title"));
                    costBean.costDate = cursor.getString(cursor.getColumnIndex("cost_date"));
                    costBean.costMoney = cursor.getString(cursor.getColumnIndex("cost_money"));
                    mCostBeanList.add(costBean);
                    Log.e("data",costBean.costMoney );
    
                }
                cursor.close();
            }
    
    
    
    
        }
    
    
    
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.wode,container,false);
            mDatabaseHelper = new DatabaseHelper(getActivity());
            mCostBeanList = new ArrayList<>();
            daka=view.findViewById(R.id.daka);
            day=view.findViewById(R.id.day);
            daka.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View view) {
                   i++;
                   int f=i;
                   daka.setText("已打卡");
                   day.setText(i+"天");
               }
           });
    
            zhichu_money=view.findViewById(R.id.zhichu_money);
            jine=view.findViewById(R.id.jine);
            yue_money=view.findViewById(R.id.yue_money);
            queding=view.findViewById(R.id.queding);
            queding.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    jin=jine.getText().toString();
                    all_1=Integer.parseInt(jin);
                    SumList();
                }
            });
    
            pieChartView = view.findViewById(R.id.pie_chart);
            setPieChartData();
            initPieChartView();
    
            return view;
        }
    
        private void setPieChartData() {
            //        colors.add(Color.rgb(85, 255, 161));//绿色 网银
    //        colors.add(Color.rgb(249, 255, 85));//黄色 柜面
    //        colors.add(Color.rgb(255, 179, 179));//粉色 电话银行
    //        colors.add(Color.rgb(199, 155, 253));//紫色 自助设备
    //        colors.add(Color.rgb(105, 108, 254));//蓝色 手机银行
    //        colors.add(Color.rgb(255, 255, 255));//白色 其他
            data = new int[]{1,2,3,4};
            for (int i = 0; i < data.length; ++i) {
    //            这里的颜色是我写了一个工具类 是随机选择颜色的  稍后你把颜色替换下
                SliceValue sliceValue = new SliceValue((float) data[i]);
                values.add(sliceValue);
            }
        }
        private void initPieChartView(){
            PieChartData pieChardata = new PieChartData();
            pieChardata.setHasLabels(false);//显示表情
            pieChardata.setHasLabelsOnlyForSelected(false);//不用点击显示占的百分比
            pieChardata.setHasLabelsOutside(false);//占的百分比是否显示在饼图外面
            pieChardata.setHasCenterCircle(true);//是否是环形显示
            pieChardata.setValues(values);//填充数据
            pieChardata.setValueLabelsTextColor(Color.TRANSPARENT);//设置值得颜色 
    //设置值得背景透明
            pieChardata.setValueLabelBackgroundColor(Color.TRANSPARENT);
            pieChardata.setCenterCircleColor(Color.TRANSPARENT);//设置环形中间的颜色
            // pieChardata.setValueLabelBackgroundEnabled(false);
            // pieChardata.setCenterCircleScale(0.98f);
            // 设置环形的大小级别 pieChardata.setCenterText1("");
            // 环形中间的文字1 pieChardata.setCenterText1Color(Color.TRANSPARENT);
            // 文字颜色 pieChardata.setCenterText1FontSize(0);//文字大小
            // pieChardata.setSlicesSpacing(0);
            // 设置间隔为0 pieChardata.setCenterText2("");
            // pieChardata.setCenterText2Color(Color.TRANSPARENT);
            // pieChardata.setCenterText2FontSize(0); pieChartView.setPieChartData(pieChardata);
            // pieChartView.setValueSelectionEnabled(false);//选择饼图某一块变大
            // pieChartView.setChartRotationEnabled(false); pieChartView.setValueTouchEnabled(false);
            // pieChartView.setCircleFillRatio(0); pieChartView.setFadingEdgeLength(0);
            // pieChartView.setClickable(false); pieChartView.setAlpha(0.9f);//设置透明度
            // pieChartView.setCircleFillRatio(1f);//设置饼图大小
            }
    
    
        private void SumList() {
            int sumzhichu = 0;
            int sumshouru = 0;
            int lastyue = 0;
            int all=0;
            for (int i = 0; i < mCostBeanList.size(); i++) {
                CostBean costBean = mCostBeanList.get(i);
                int  costMoney = Integer.parseInt(costBean.getCostMoney());
    
                if(costMoney<=0){
                    sumzhichu += costMoney;
                }else{
                    sumshouru += costMoney;
                }
            }
            lastyue = sumzhichu+sumshouru;
            all=all_1+lastyue;
            //shouru.setText(String.valueOf(sumshouru));
            zhichu_money.setText(String.valueOf(sumzhichu));
            yue_money.setText(String.valueOf(all));
    
        }
    
    
    
    
    
    }
    
    sifragment

    将增加收入的余额进行修改;

  • 相关阅读:
    查看表中bytea类型的字段内容
    Js中生成32位随机id
    VS Code操作指南
    记录一次非常简单的Win10安装
    Typora中下载并安装主题
    Win 10下隐藏任务栏图标B & O Play Audio Control
    IDEA基本使用
    Eclipse中安装反编译器(中文版)
    Eclipse设置控制台不自动弹出
    解决Eclipse控制台中文乱码的情况
  • 原文地址:https://www.cnblogs.com/zuoshenmedoudui/p/12985373.html
Copyright © 2011-2022 走看看