android项目之小闹钟之准备篇

来源:互联网 发布:淘宝手机降价通知 编辑:程序博客网 时间:2024/06/08 03:15

今天我向大家介绍一个android的简单的小项目,在我们的生活中,闹钟也是我们的生活小助手,在这里我们做一个小闹钟,仅限于学习与开发使用,不足之处,希望大家多多提出宝贵意见.

首先我们来准备一下我们的UI,但是我的UI非常之简陋,(没办法,本人没有艺术细胞),好啦,这都不重要,关键是我们要学到东西.

废话不多说,直接上xml:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent" android:background="@drawable/back"android:gravity="center_horizontal"><TimePicker android:id="@+id/time" android:layout_width="fill_parent"android:layout_height="wrap_content" /><TextView android:id="@+id/msg" android:layout_width="fill_parent"android:layout_height="wrap_content" android:text="当前没有设置闹钟" /><Button android:id="@+id/set" android:layout_width="fill_parent"android:layout_height="wrap_content" android:text="设置闹钟" /><ListView    android:id="@+id/listView"    android:layout_width="match_parent"    android:layout_height="wrap_content"></ListView></LinearLayout>


<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"     android:background="@drawable/work">    </LinearLayout>

2.我为大家谈一下我的架构,

我们通过一个TimePicker来设置时间,然后我们会将你设置的时间显示在ListView上,

在这里,如何的动态刷新便成为了难点,因为你不自动刷新,通过listview自己识别是非常慢的,会造成卡顿现象

我们还可以在我们的listView上长按删除我们设置的闹钟

闹钟响起后,会有声音,会弹出一个对话框,紧接着,客户会受到一个通知(Notification),

用户点击这个通知后回跳转到一个界面(这个项目只是一个简单地框架,大家可以自己往上面添加新的功能,比如备忘录等)

3.用到的知识点;

BroadReceiver

PendingIntent

Intent

activity跳转

Notification

MediaPlayer

AlarmManger

timePicker

主要的知识点就是这么多,其实大家还可以考虑一下服务(Service)

最后,界面的大致效果如下:



2 0
原创粉丝点击