我正在尝试更改时间选择器对话框片段的默认颜色。
现在我不知道我应该做什么。
这就是我设法将我的主题设置为(没有actionBar):
but this is the dialog i get:
这是我的 xml 样式文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/color_accent</item>
<item name="colorPrimaryDark">@color/color_secondary</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:statusBarColor">@color/color_primary</item>
</style>
</resources>
我的颜色文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="flat_text">#f14268</color>
<color name="background_flatbtn">#fff</color>
<color name="color_accent">#f14268</color>
<color name="color_primary">#d83b5d</color>
<color name="color_secondary">#d83b5d</color>
</resources>
mytimepicker 片段:
public class DialogHandler extends DialogFragment
implements TimePickerDialog.OnTimeSetListener {
Context context;
public DialogHandler(Context context){
this.context=context;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
TimePickerDialog dialog= new TimePickerDialog(new ContextThemeWrapper(getActivity(),R.style.AppTheme), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
// Create a new instance of TimePickerDialog and return it
return dialog;
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Do something with the time chosen by the user
Toast.makeText(context, "your time is selected",Toast.LENGTH_LONG).show();
}
}
我的对话调用:
DialogHandler newFragment = new DialogHandler(getApplicationContext());
newFragment.show(getSupportFragmentManager() , "time_Picker");
请帮我 。
提前致谢 :)