Skip to content

This Library provides a very simple implementation of some android material picker's dialogs which were not available as open source library. It includes android Number/Interval picker which can be used as Year picker, Month picker and any time duration Picker. It also includes Material Gender Picker Dialog which was much required.

ch-muhammad-adil/Android-Material-Picker-Dialog

Repository files navigation

Android Material Picker Dialog

This Library provides a very simple implementation of some android material picker's dialogs which were not available as open source library. It includes android Number/Interval picker which can be used as Year picker, Month picker and any time duration Picker. It also includes Material Gender Picker Dialog which was much required.

#Screenshots pickerspickers

##Compile Library jCenter

dependencies {
    ....
    compile 'com.github.ch-muhammad-adil:MaterialPickerDialog:1.0.3'
    ....
}

##Compile Library maven

dependencies {
    repositories {
        mavenCentral()
    }
    compile 'com.github.ch-muhammad-adil:MaterialPickerDialog:1.0.3'
}

##Simple Code for Number Picker

////Using NumberPicker as an interval

NumberPickerDialog dialog=new NumberPickerDialog(MainActivity.this, -50, 50, new NumberPickerDialog.NumberPickerCallBack() {
                    @Override
                    public void onSelectingValue(int value) {
                        Toast.makeText(MainActivity.this, "Selected "+String.valueOf(value), Toast.LENGTH_SHORT).show();
                    }
                });
                dialog.show();

////Using number picker as year interval

NumberPickerDialog dialog=new NumberPickerDialog(MainActivity.this, 1992, 2017, new NumberPickerDialog.NumberPickerCallBack() {
                    @Override
                    public void onSelectingValue(int value) {
                        Toast.makeText(MainActivity.this, "Selected Year "+String.valueOf(value), Toast.LENGTH_SHORT).show();
                    }
                });
                dialog.show();

##Simple Code for Gender Picker

////Using gender picker

GenderPickerDialog dialog=new GenderPickerDialog(MainActivity.this);
                dialog.setOnSelectingGender(new GenderPickerDialog.OnGenderSelectListener() {
                    @Override
                    public void onSelectingGender(String value) {
                        Toast.makeText(MainActivity.this, "Selected "+value, Toast.LENGTH_SHORT).show();
                    }
                });
                dialog.show();

##Do Add permissions for vibration in your menifest file.

<uses-permission android:name="android.permission.VIBRATE" />

##Color Attributes of Material Picker Dialog

If you override these attributes in your colors.xml file under res/values you can customize your material picker dialog

    <!--use these color attributes to customize Material Picker Dialog-->

    <color name="MPD_primaryColor">@color/primaryColor</color>
    <color name="MPD_primaryColorLight">#C5CAE9</color>
    <color name="MPD_backGroundColor">#FFF</color>
    <color name="MPD_pickerItemColorUnSelected">#00FFFFFF</color>
    <color name="MPD_pickerItemColorSelected">@color/MPD_primaryColor</color>
    <color name="MPD_pickerItemTextColorUnSelected">#444</color>
    <color name="MPD_pickerItemTextColorSelected">#bbffffff</color>
    <color name="MPD_pickerSelectedTextColor">#FFF</color>

##Localization Attributes You can update any text and message or you can add localization using these attributes. You just need to override these string attributes in your strings.xml file under res/values.

    <string name="MPD_action_done">done</string>
    <string name="MPD_action_cancel">cancel</string>
    <string name="MPD_male">Male</string>
    <string name="MPD_female">Female</string>
    <string name="MPD_empty_message">value can not be empty</string>
    <string name="MPD_incorrect_message">please select correct value</string>

##TODO

  • Number Picker Requires support for reverse ordering
  • Orientation change control is not handled yet in case if user changes orientation and dialog is open
  • Need to add horizontal movement of number picker items

This is my first implementation of any open source library so your suggestions will be really helpful"

Licence

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

This Library provides a very simple implementation of some android material picker's dialogs which were not available as open source library. It includes android Number/Interval picker which can be used as Year picker, Month picker and any time duration Picker. It also includes Material Gender Picker Dialog which was much required.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages