【开源】BetterPickers
BetterPickers
介绍:
外观很不错的自定义数字输入面板,可以输入数字、时间、日期等等跟数字有关的内容。
运行效果:

使用说明:
在activity中implements回调函数:
public class MyActivity extends Activity implements DatePickerDialogFragment.DatePickerDialogHandler {
@Override
public void onCreate(Bundle savedInstanceState) {
// ...
}
@Override
public void onDialogDateSet(int year, int monthOfYear, int dayOfMonth) {
// Do something with your date!
}
}
使用builder创建一个特定主题的dailog
DatePickerBuilder dpb = new DatePickerBuilder()
.setFragmentManager(getSupportFragmentManager())
.setStyleResId(R.style.BetterPickersDialogFragment);
dpb.show();
你可以自定义自己的theme属性,当前支持以下主题的自定义:
bpDialogBackground :: the drawable (preferably a 9-patch) used as a window background for the DialogFragment bpTextColor :: the color (optionally state list) for all text in the DialogFragment bpDeleteIcon :: the drawable (optionally state list) for the delete button bpCheckIcon :: the drawable (optionally state list) for the check button in the DateDialogPicker bpKeyBackground :: the drawable (optionally state list) for the keyboard buttons bpButtonBackground :: the drawable (optionally state list) for the Set, Cancel, and Delete buttons bpDividerColor :: the color used for the DialogFragment dividers bpKeyboardIndicatorColor :: the color used for the ViewPagerIndicator on the DateDialogPicker
在style.xml中将上述属性一一对应:
<style name="MyCustomBetterPickerTheme">
<item name="bpDialogBackground">@drawable/custom_dialog_background</item>
<item name="bpTextColor">@color/custom_text_color</item>
<item name="bpDeleteIcon">@drawable/ic_backspace_custom</item>
<item name="bpCheckIcon">@drawable/ic_check_custom</item>
<item name="bpKeyBackground">@drawable/key_background_custom</item>
<item name="bpButtonBackground">@drawable/button_background_custom</item>
<item name="bpDividerColor">@color/custom_divider_color</item>
<item name="bpKeyboardIndicatorColor">@color/custom_keyboard_indicator_color</item>
</style>
然后你就可以使用自己的自定义主题了:
DatePickerBuilder dpb = new DatePickerBuilder()
.setFragmentManager(getSupportFragmentManager())
.setStyleResId(R.style.MyCustomBetterPickerTheme);
dpb.show();
posted on 2015-03-23 17:05 wasdchenhao 阅读(314) 评论(0) 收藏 举报
浙公网安备 33010602011771号