下面列出了android.app.AlertDialog#THEME_HOLO_LIGHT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public int getTheme(Context context){
SharedPreferences preferences = SharePreferenceManager.getApplicationSetting(context);
int theme = preferences.getInt(ApplicationSetting.KEY_THEME, ApplicationTheme.LIGHT.getKey());
if (theme == ApplicationTheme.LIGHT.getKey()){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return android.R.style.Theme_Material_Light_Dialog_Alert;
}else return AlertDialog.THEME_HOLO_LIGHT;
}else{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return android.R.style.Theme_Material_Dialog_Alert;
}else return AlertDialog.THEME_HOLO_DARK;
}
}
/**
* Set correct theme for day/night modes
*/
private int setTheme(boolean nightMode) {
if (nightMode) {
return AlertDialog.THEME_HOLO_DARK;
} else {
return AlertDialog.THEME_HOLO_LIGHT;
}
}
@Override
protected Dialog onCreateDialog(int id)// ��дonCreateDialog����
{
switch (id) {
case DATE_DIALOG_ID:// ��������ѡ��Ի���
return new DatePickerDialog(this, AlertDialog.THEME_HOLO_LIGHT,
mDateSetListener, mYear, mMonth, mDay);
}
return null;
}
protected void showDialog (String message, boolean error)
{
AlertDialog.Builder dlg;
dlg = new AlertDialog.Builder (this.context, error ? AlertDialog.THEME_HOLO_DARK : AlertDialog.THEME_HOLO_LIGHT);
dlg.setMessage (message);
dlg.setCancelable (true);
dlg.setNeutralButton ("OK", null);
dlg.show ();
}
public void showDatePicker() {
DatePickerDialog cc = new DatePickerDialog(getActivity(), AlertDialog.THEME_HOLO_LIGHT, dateSetListener, 1990,
1, 1);
cc.show();
}
public void showDatePicker() {
DatePickerDialog cc = new DatePickerDialog(getActivity(), AlertDialog.THEME_HOLO_LIGHT, dateSetListener, 2008,
1, 1);
cc.show();
}