https://github.com/twinkle942910/monthyearpicker
Fancy year and month picker library for your android app
https://github.com/twinkle942910/monthyearpicker
android calendar java library picker-dialog
Last synced: 7 months ago
JSON representation
Fancy year and month picker library for your android app
- Host: GitHub
- URL: https://github.com/twinkle942910/monthyearpicker
- Owner: Twinkle942910
- License: apache-2.0
- Created: 2017-06-13T20:22:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-02T20:29:47.000Z (over 7 years ago)
- Last Synced: 2025-05-30T16:33:38.079Z (8 months ago)
- Topics: android, calendar, java, library, picker-dialog
- Language: Java
- Size: 151 KB
- Stars: 35
- Watchers: 1
- Forks: 22
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MonthYearPicker
Fancy year and month picker library for your android app
## How to use?
### Maven
```Maven
com.github.twinkle942910
monthyearpicker
0.0.1
aar
```
### Gradle
```Gradle
dependencies {
compile 'com.github.twinkle942910:monthyearpicker:0.0.1'
}
```
## Demonstration
| And you can pick a year | You can pick a month |
| ------------------------ | -------------------- |
|
|
|
## You can simply create your dialog in code, using next lines
```Java
Calendar calendar = Calendar.getInstance();
calendar.set(2010,01,01);
YearMonthPickerDialog yearMonthPickerDialog = new YearMonthPickerDialog(this, calendar, new YearMonthPickerDialog.OnDateSetListener() {
@Override
public void onYearMonthSet(int year, int month) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM yyyy");
yearMonth.setText(dateFormat.format(calendar.getTime()));
}
});
```
1st argument - Context.
2nd - Calendar.
3nd - Date set listener.
### And after this just show it whenever you need it to appear.
```Java
yearMonthPickerDialog.show();
```
## If you want to add your style then add themeId to the constructor as a third argument
for exemple:
Add your custom style to android resources
```XML
<item name="colorControlNormal">@android:color/white</item>
<item name="colorControlActivated">@color/colorPrimary</item>
<item name="textColorAlertDialogListItem">@android:color/white</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColorPrimary">@android:color/black</item>
<item name="android:windowBackground">@drawable/dialog_background</item>
```
It would add colors to the controls and text.
Then add a content drawable for backgound. Example:
```XML
```
use example : ``` R.style.MyDialogTheme ```
And you will have your custom theme applied.
## Customizing dialog title
If you want to change title text color, then add a int color value as a 4th constructor parameter.
use example : ``` R.color.MyTextTitleColor ```
Also, if you want to change color of title view, you have to change you main theme primary color, because it depends on it's value.
## Set a custom year range
If you want the displayed values of year vary within a range, you have to set the first (min) and the last (max) year:
```Java
yearMonthPickerDialog.setMinYear(2000);
yearMonthPickerDialog.setMaxYear(2020);
```
### Check demonstraction project for more details.