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();
            }
        });
    }
  • 相关阅读:
    Android四大组件应用系列——使用BroadcastReceiver和Service实现倒计时
    IOS之UITabBarController
    Android之TelephonyManager
    Android四大组件应用系列——Activity与Service交互实现APK下载
    Android之PowerManager&BatteryManager
    ASP.NET MVC 下拉列表使用小结
    Module Zero之角色管理
    Module Zero之用户管理
    Module-Zero之版本管理
    Module-Zero之租户管理
  • 原文地址:https://www.cnblogs.com/hhw12345/p/14909608.html
Copyright © 2011-2022 走看看