当前位置:   article > 正文

Androidstudio课程设计,备忘录记事本实现_android studio大作业

android studio大作业

android studio大作业,android studio课程设计,记事本实现


先看效果图

请添加图片描述

功能点实现:

登录,注册,记事本分类添加,删除,数据分析统计报表,数据库使用SQLlite


部分实现代码

public class MainActivity extends BaseActivity {
    private String titles[] = {"记账", "打卡", "便签"};
    private int position = 0;

    private ListView listview;
    private ListAdapter mListAdapter;
    private ContentDao mContentDao;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {

        listview = findViewById(R.id.listview);
        mListAdapter = new ListAdapter(MainActivity.this);
        listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                ContentInfo contentInfo = mListAdapter.getItem(position);


                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle("确定要删除吗?");
                builder.setMessage("删除后的数据将无法恢复");
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {


                        if (mContentDao == null) {
                            mContentDao = new ContentDao(MainActivity.this);
                        }
                        int row = mContentDao.delete(contentInfo.get_id());
                        if (row > 0) {
                            if (null != mListAdapter) {
                                mListAdapter.setList(mContentDao.queryAll());
                            }

                            showToast("删除成功");
                        } else {
                            showToast("删除失败");
                        }
                    }
                });

                builder.show();


                return true;
            }
        });


    }

    @Override
    protected void setListener() {
        findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {


            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle("新建分类标签");
                builder.setSingleChoiceItems(titles, 0, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        position = which;
                        showToast(titles[which]);
                    }
                });
                builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (position == 0) {
                            startActivityForResult(new Intent(MainActivity.this, ChargeActivity.class), 200);
                        } else if (position == 1) {
                            startActivityForResult(new Intent(MainActivity.this, LocationActivity.class), 200);
                        } else {
                            startActivityForResult(new Intent(MainActivity.this, StickyActivity.class), 200);
                        }

                    }
                });

                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                builder.show();
            }
        });

        findViewById(R.id.chart).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, ChartActivity.class));
            }
        });

    }

    @Override
    protected void initData() {
        if (mContentDao == null) {
            mContentDao = new ContentDao(this);
        }
        listview.setAdapter(mListAdapter);
        mListAdapter.setList(mContentDao.queryAll());
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 200) {
            initData();

        }
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号