基于Android开发的备忘录软件(创建、通知)

本文介绍了基于Android开发的一款备忘录应用,该应用集成了备忘录创建和定时提醒功能。系统设计包括备忘录的添加、删除、编辑,以及通过广播实现的闹钟提醒。开发者通过适配器、ListView、CardView和AlarmService等技术实现了功能,并分享了在开发过程中的学习体会。
摘要由CSDN通过智能技术生成

系统概述

结合本学期课程所学的关于Android通知的知识以及期中期末作业的记事本软件应用开发,我在之前就有想法做一个将两者结合的应用即备忘录,既能记事又能提醒。
具体定义为:具有备忘录的基本功能,支持备忘事项的创建,同时提供定时提醒功能(在指定的时间到达前在通知栏上弹出相应的通知来提醒用户)。

系统总体设计

系统设计图
其中,删除用长按ListView实现,添加由点击按钮实现,编辑由点击ListView实现。闹钟提醒由广播通知实现。

系统设计与实现部分

关键代码及说明

①构造xml文件,使用ReclcyerView控件实现备忘录的列表显示,通过CardView控件实现备忘录的卡片式显示,以及添加FloatingActionButton控件进行添加活动的跳转。TextView和ImageView实现细节展示。

(1)activity_main.xml(部分代码)

 <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="670dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="14dp"
        android:src="@drawable/ic_add"
        app:backgroundTint="#FF2229" />

(2)activity_edit.xml(部分代码)

<LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp">

        <LinearLayout
            android:layout_width="275dp"
            android:layout_height="122dp"
            android:layout_weight="5"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="289dp"
                android:layout_height="59dp"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/dateText"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="现在是2020/1/1"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textSize="25sp" />

                <TextView
                    android:id="@+id/timeText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="00:00"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textSize="25sp" />
            </LinearLayout>

            <TextView
                android:id="@+id/alarmView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="提醒时间:"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="25sp" />

        </LinearLayout>

        <ImageButton
            android:id="@+id/alarmButton"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/alarm"
            android:onClick="setAlarm" />
    </LinearLayout>

(3)note_card.xml(部分代码)

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_gravity="center_horizontal"
    android:layout_marginBottom="2dp"
    android:layout_marginTop="2dp">


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="22dp"
            android:layout_gravity="center_horizontal"
            android:padding="0dp"
            android:layout_margin="0dp"
            android:baselineAligned="false"
            android:layout_marginBottom="1dp">

            <TextView
                android:id="@+id/textDate"
                android:layout_width="118dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="left|center_vertical"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#908d8d"
                android:textSize="16sp"
                android:typeface="sans" />

            <Space
                android:layout_width="5dp"
                android:layout_height="match_parent" />

            <TextView
                android:id="@+id/textTime"
                android:layout_width="105dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="left|center_vertical"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#908d8d"
                android:textSize="16sp"
                android:typeface="sans" />

            <Space
                android:layout_width="224dp"
                android:layout_height="match_parent"
                android:layout_weight="1" />

            <ImageView
                android:id="@+id/alarm"
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="0"
                android:src="@drawable/alarm" />
        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="58dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/mainText"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dp"
            android:textSize="16sp"
            android:typeface="sans"
            android:maxLines="2"
            android:ellipsize="end"
            android:lineSpacingMultiplier="1.2"/>
    </LinearLayout>
</LinearLayout>

②编写Note.java,创建备忘录的实体类,通过get和set方法获取和传入对应属性值。

public class Note {
   

    private int id;
    private int num;//列表中的位置
    private String textDate;
    private String textTime;
    private String alarm;
    private String mainText;


    public Note(){
   }

    public Note(int num, int tag, String textDate, String textTime, String alarm
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值