Android多功能时钟.docx
- 文档编号:26821255
- 上传时间:2023-06-23
- 格式:DOCX
- 页数:32
- 大小:55.99KB
Android多功能时钟.docx
《Android多功能时钟.docx》由会员分享,可在线阅读,更多相关《Android多功能时钟.docx(32页珍藏版)》请在冰豆网上搜索。
Android多功能时钟
Android多功能时钟开发项目
1.功能模块
主要有时钟,闹钟,计时,秒表功能
2.代码布局
activity_main.xml
xmlversion="1.0"encoding="utf-8"?
>
android=" android: id="@+id/container" android: layout_width="match_parent" android: layout_height="match_parent" > android: id="@android: id/tabhost" android: layout_width="match_parent" android: layout_height="match_parent"> android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical"> android: id="@android: id/tabs" android: layout_width="match_parent" android: layout_height="wrap_content"/> android: id="@android: id/tabcontent" android: layout_width="match_parent" android: layout_height="match_parent"> android: id="@+id/tabTime" android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical"> android: id="@+id/tvTime" android: layout_width="match_parent" android: layout_height="match_parent" android: gravity="center" android: textAppearance="? android: textAppearanceLarge" /> android: id="@+id/tabAlarm" android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical"> android: id="@+id/lvAlarmList" android: layout_width="match_parent" android: layout_height="0dp" android: layout_weight="1" > android: id="@+id/tabTimer" android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical"> android: orientation="horizontal" android: layout_width="match_parent" android: layout_height="0dp" android: layout_weight="1" > android: singleLine="true" android: inputType="number" android: id="@+id/edHour" android: layout_width="0dp" android: layout_height="wrap_content" android: layout_weight="1"/> android: text=": " android: layout_width="wrap_content" android: layout_height="wrap_content"/> android: singleLine="true" android: inputType="number" android: id="@+id/edMinute" android: layout_width="0dp" android: layout_height="wrap_content" android: layout_weight="1"/> android: text=": " android: layout_width="wrap_content" android: layout_height="wrap_content"/> android: singleLine="true" android: inputType="number" android: id="@+id/edSec" android: layout_width="0dp" android: layout_height="wrap_content" android: layout_weight="1"/> android: id="@+id/btGroup" android: layout_width="match_parent" android: layout_height="wrap_content" android: orientation="horizontal"> android: id="@+id/tabStopWatch" android: layout_width="match_parent" android: layout_height="match_parent" android: orientation="vertical"> android: orientation="horizontal" android: layout_width="match_parent" android: layout_height="wrap_content"> android: text="0" android: id="@+id/timeHour" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content" /> android: text=": " android: layout_width="wrap_content" android: layout_height="wrap_content"/> android: text="0" android: id="@+id/timeMinute" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content" /> android: text=": " android: layout_width="wrap_content" android: layout_height="wrap_content"/> android: text="0" android: id="@+id/timeSec" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content" /> android: text="." android: layout_width="wrap_content" android: layout_height="wrap_content"/> android: text="0" android: id="@+id/timeMSec" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content" /> android: id="@+id/lvWatchTimeList" android: layout_weight="1" android: layout_width="match_parent" android: layout_height="0dp"> android: orientation="horizontal" android: layout_width="match_parent" android: layout_height="wrap_content"> android: id="@+id/btnSWStatr" android: text="@string/Start" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content"/> android: id="@+id/btnSWPause" android: text="@string/Pause" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content"/> android: id="@+id/btnSWResume" android: text="@string/Resume" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content"/> android: id="@+id/btnSWLap" android: text="@string/Lap" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content"/> android: id="@+id/btnSWRest" android: text="@string/Reset" android: layout_weight="1" android: layout_width="0dp" android: layout_height="wrap_content"/> alarm_play_aty.xml xmlversion="1.0"encoding="utf-8"? > android=" android: layout_width="match_parent" android: layout_height="match_parent"> android: textAppearance="? android: attr/textAppearanceLarge" android: text="时间到...." android: gravity="center" android: layout_width="match_parent" android: layout_height="match_parent"/> strings.xml AndroidManifest.xml xmlversion="1.0"encoding="utf-8"? > android=" package="com.mryang.myclock"> android: allowBackup="true" android: icon="@mipmap/ic_launcher" android: label="多功能时钟" android: roundIcon="@mipmap/ic_launcher_round" android: supportsRtl="true" android: theme="@style/AppTheme"> name=".MainActivity"> name="android.intent.action.MAIN"/> name="android.intent.category.LAUNCHER"/> android: name=".AlarmReceiver" android: enabled="true" android: exported="true"> name=".PlayAlarmAty"> 3.资源文件 app\src\main\res\raw\music.mp3 4.设计代码 AlarmReceiver.java packagecom.mryang.myclock; importandroid.app.AlarmManager; importandroid.app.PendingIntent; importandroid.content.BroadcastReceiver; importandroid.content.Context; importandroid.content.Intent; importandroid.util.Log; publicclassAlarmReceiverextendsBroadcastReceiver{ @Override publicvoidonReceive(Contextcontext,Intentintent){ //TODO: ThismethodiscalledwhentheBroadcastReceiverisreceiving //anIntentbroadcast. //thrownewUnsupportedOperationException("Notyetimplemented"); Log.d("s","闹钟执行了"); AlarmManageram=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); am.cancel(PendingIntent.getBroadcast(context,getResultCode(),newIntent(context,AlarmReceiver.class),0)); Intentintent1=newIntent(context,PlayAlarmAty.class); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1); } } AlarmView.java packagecom.mryang.myclock; importandroid.app.AlarmManager; importandroid.app.AlertDialog; importandroid.app.PendingIntent; importandroid.app.TimePickerDialog; importandroid.content.Context; importandroid.content.DialogInterface; importandroid.content.Intent; importandroid.content.SharedPreferences; importandroid.support.annotation.Nullable; importandroid.util.AttributeSet; importandroid.util.Log; importandroid.view.View; importandroid.widget.AdapterView; importandroid.widget.ArrayAdapter; importandroid.widget.Button; importandroid.widget.LinearLayout; importandroid.widget.ListView; importandroid.widget.TimePicker; importjava.util.Calendar; publicclassAlarmViewextendsLinearLayout{ publicAlarmView(Contextcontext){ super(context); init(); } publicAlarmView(Contextcontext,@NullableAttributeSetattrs){ super(context,attrs); init(); } publicAlarmView(Contextcontext,@NullableAttributeSetattrs,intdefStyleAttr){ super(context,attrs,defStyleAttr); init(); } privatevoidinit()
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Android 多功能 时钟