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();
            }
        });
    }
  • 相关阅读:
    Git使用笔记
    javascript获取表单值的7种方式
    javascript里阻止事件冒泡
    PHP面向对象04_串行化
    MySQL数据库锁定机制
    SAP R3和JAVA交换数据之JCO
    @XStreamAlias使用
    JCO 自定义DestinationDataProvider
    IBM websphere MQ 消息发送与获取
    WebSphere MQ 入门指南
  • 原文地址:https://www.cnblogs.com/hhw12345/p/14909608.html
Copyright © 2011-2022 走看看