zoukankan      html  css  js  c++  java
  • 寒假学习日报29

    public class DatabaseHelper extends SQLiteOpenHelper {
        public DatabaseHelper(Context context) {
            super(context,"account_daily", null, 1);
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL("create table if not exists account_cost(" +
            "id integer primary key, " +
            "cost_title varchar, " +
            "cost_date varchar, " +
            "cost_money varchar)");
        }
    fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
                View viewDialog = inflater.inflate(R.layout.new_cost_data, null);
                final EditText title = (EditText) viewDialog.findViewById(R.id.et_cost_title);
                final EditText money = (EditText) viewDialog.findViewById(R.id.et_cost_money);
                final DatePicker date = (DatePicker) viewDialog.findViewById(R.id.dp_cost_date);
                builder.setView(viewDialog);
                builder.setTitle("New Cost");
                builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        CostBean costBean = new CostBean();
                        costBean.costTitle = title.getText().toString();
                        costBean.costMoney = money.getText().toString();
                        costBean.costDate = date.getYear() + "-" +(date.getMonth() + 1) + "-" +
                                date.getDayOfMonth();
    
                        mDatabaseHelper.insertCost(costBean);
                        mCostBeanList.add(costBean);
                        mAdapter.notifyDataSetChanged();
                    }
                });
                builder.setNegativeButton("Cancel",null);
                builder.create().show();
            }
        });
    }
  • 相关阅读:
    java并发编程(1)并发程序的取消于关闭
    Matlab插值函数
    log4j的配置
    spring-mvc注解(mvc:annotation-driver,JSON,配置详解)
    matlab画图函数plot()/set/legend
    matlab 曲线拟合
    Linux安装库文件(环境变量和makefile)
    css生成彩色阴影
    JSON.stringify()还可以这么用
    ES6中新增的数组知识记录
  • 原文地址:https://www.cnblogs.com/hhw12345/p/14909608.html
Copyright © 2011-2022 走看看