• 寒假学习日报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();
            }
        });
    }
  • 相关阅读:
    CentOS7上安装FTP服务
    CentOS7上安装Nginx、PHP、MySQL
    iOS-高性能编程之多线程
    Autoloader什么鬼
    PHP调用外部命令
    PHP使用Redis【重要】
    Windows系统上Redis的安装
    利用nginx与ffmpeg搭建流媒体服务器
    Ubuntu14.04上安装Composer
    find the most comfortable road(并差集,找差值最小的权值)
  • 原文地址:https://www.cnblogs.com/hhw12345/p/14909608.html
Copyright © 2020-2023  润新知