DeskClock分析文档
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
//静音模式下闹铃响开启
if (pref.isChecked()) {Log.e(\
ringerModeStreamTypes &= ~ALARM_STREAM_TYPE_BIT; } else {Log.e(\
//静音模式下闹铃响关闭
ringerModeStreamTypes |= ALARM_STREAM_TYPE_BIT; }
Settings.System.putInt(getContentResolver(),
Settings.System.MODE_RINGER_STREAMS_AFFECTED, ringerModeStreamTypes);
return true; }
return super.onPreferenceTreeClick(preferenceScreen, preference); }
public boolean onPreferenceChange(Preference pref, Object newValue) { final ListPreference listPref = (ListPreference) pref; final int idx = listPref.findIndexOfValue((String) newValue); listPref.setSummary(listPref.getEntries()[idx]); return true; }
private void refresh() {Log.e(\ final CheckBoxPreference alarmInSilentModePref =
(CheckBoxPreference) findPreference(KEY_ALARM_IN_SILENT_MODE);
final int silentModeStreams =
Settings.System.getInt(getContentResolver(),
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); alarmInSilentModePref.setChecked(
(silentModeStreams & ALARM_STREAM_TYPE_BIT) == 0); //再响间隔
final ListPreference snooze =
(ListPreference) findPreference(KEY_ALARM_SNOOZE); snooze.setSummary(snooze.getEntry()); snooze.setOnPreferenceChangeListener(this); } }
31
DeskClock分析文档
五.布局文件
? Include的功能
在一个项目中我们可能会需要用到相同的布局设计,如果都写在一个xml文件中,代码显得很冗余,并且可读性也很差,所以我们可以把相同布局的代码单独写成一个模块,然后用到的时候可 以通过
include的功能:可把多个layout.xml布局文件整合到一个布局文件中,便于布局文件的管理,增加了布局文件的可读性和可从用性 desk_clock.xml文件中有这样一段代码:
这里include引入了desk_clock_buttons.xml文件中的布局 style=\ android:layout_height=\ android:layout_width=\ android:layout_weight=\ android:src=\ android:contentDescription=\ /> style=\ android:layout_height=\ android:layout_width=\ android:layout_weight=\ android:src=\ android:contentDescription=\ /> style=\ android:layout_height=\ android:layout_width=\ android:layout_weight=\ 32 DeskClock分析文档 android:src=\ android:contentDescription=\ /> style=\ android:layout_height=\ android:layout_width=\ android:layout_weight=\ android:src=\ android:contentDescription=\ /> 33 DeskClock分析文档 六.个人总结 通过对第一个模块的研究,除了把之前培训学习的内容全部融入到模块中,还学习了一些新的知识,虽然开始感觉很茫然,无从下手,但通过和团队其他成员的交流,慢慢的找到些 自己的学习方法,相信在以后的工作中,能更好的融入到项目中。 BUG: ? 当时间显示为am/pm模式,小时是两位数时,“午”字会显示出来。 调整布局文件,修改desk_clock.xml参数设置。 ? 解决办法: 34 DeskClock分析文档 附件: 类关系图 35