首先,说明一下:本人大三,刚自学完android基础知识,利用寒假一个月左右的时间,开发了一个闹钟小程序,趁着开学,印象还很深,热情还未减,把过程整理记录下来。这样自己以后也好复习,或许还能帮到有需要的同学。好了,不废话了。先看一下闹钟几个界面(基本上是照着小米自带的闹钟做的界面)。
基本的界面就是这样的了。(开发中的控件都是用的系统自带的,包括一些图片也没有精心制作,我暂时关注的是功能实现,谅解)
闹钟设置界面的布局文件如下(由于许多同类控件布局差不多,就都抽取到一个style文件中了):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_color"
android:padding="10dip" >
<LinearLayout
android:id="@+id/ll_alarm_clock_setting_flag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_alarm_clock_setting_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btn_cancel" />
<Button