EditSpinner

An EditText which supports spinner FOR API LEVEL >= 11



Download Demo APK


Gradle Dependency

Download

repositories {
    ...
    jcenter()
}

dependencies {
    implementation 'com.reginald:editspinner:1.1.0'
}

Usage

key properties:

attr required/optional(default value) meaning
dropDownDrawable required dropdown drawable shown on the right of the EditText
dropDownDrawableWidth optional, default using drawable intrinsic width width of dropdown drawable
dropDownDrawableHeight optional, default using drawable intrinsic height height of dropdown drawable
dropDownDrawableSpacing optional, default is 0 the spacing between edittext area and dropdown drawable area

More Usages

In some cases, you want to make it uneditable. You can

use android:editable in xml to disable editable:

android:editable="false"

or set it dynamically:

mEditSpinner.setEditable(false);
        // set the dropdown drawable on the right of EditText and its size
        mEditSpinner.setDropDownDrawable(getResources().getDrawable(R.drawable.picker), 60, 60);

        // set the spacing bewteen Edited area and DropDown click area
        mEditSpinner.setDropDownDrawableSpacing(50);

        // set DropDown popup window background
        mEditSpinner.setDropDownBackgroundResource(R.drawable.your_custom_dropdown_bkg);

        // set DropDown animation of the popup window
        mEditSpinner.setDropDownAnimationStyle(R.style.CustomPopupAnimation);
        // triggered when dropdown popup window dismissed
        mEditSpinner.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
            }
        });

        // triggered when dropdown popup window shown
        mEditSpinner.setOnShowListener(new EditSpinner.OnShowListener() {
            @Override
            public void onShow() {
            }
        });

        // it converts the item in the list to a string shown in EditText.
        mEditSpinner.setItemConverter(new EditSpinner.ItemConverter() {
            @Override
            public String convertItemToString(Object selectedItem) {
            }
        });

        // triggered when one item in the list is clicked
        mEditSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            }
        });

License

Copyright 2019 xyxyLiu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License 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.