Home

Awesome

SmartMaterialSpinner

current License

The best Android spinner library for your android application with more customization

Available on Play Store

<a href="https://play.google.com/store/apps/details?id=com.chivorn.smsp.demojava" target="_blank"> <img src="https://github.com/Chivorns/Resources/blob/master/google-play-badge.png" alt="Play Store" width="140" "> </a>

Available features

Spinner mode

Dropdown ModeDialog ModeSearchable Mode
<img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_dropdown.gif" width="250" ><img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_dialog.gif" width="250" ><img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_searchable.gif" width="250" >

Outlined Style

<img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_outlined.gif" width="250" >

Searchable spinner

Spinner item

Hint Label

Floating Label

Error Label

Color customization to:

Empty dropdown clickable

Underline

Re-selectable feature

RTL (Right To Left) feature

Typeface (Custom font)

Screenshot Demo

<table border="0"> <tr> <td> <a target="_blank"> <img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_home.jpg" alt="SmartMaterialSpinner" width="250" > </a> </td> </table>

Usage

Add the dependencies to your gradle file:

dependencies {
    implementation 'com.github.chivorns:smartmaterialspinner:2.0.0'
}

Add SmartMaterialSpinner to your layout:

    <com.chivorn.smartmaterialspinner.SmartMaterialSpinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:smsp_errorText="This is error text. You can show it as single line or multiple lines using attr smsp_multilineError"
        app:smsp_floatingLabelColor="#1976D2"
        app:smsp_floatingLabelText="Floating Label Text"
        app:smsp_hint="Hint Text"
        app:smsp_hintColor="#388E3C"
        app:smsp_itemColor="#512DA8"
        app:smsp_itemListColor="#7C4DFF"
        app:smsp_itemListHintBackgroundColor="#808080"
        app:smsp_itemListHintColor="#FFFFFF"
        app:smsp_multilineError="false"
        app:smsp_selectedItemListColor="#FF5252" />

In Java class

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.chivorn.smartmaterialspinner.SmartMaterialSpinner;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private SmartMaterialSpinner<String> spProvince;
    private SmartMaterialSpinner<String> spEmptyItem;
    private List<String> provinceList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.smart_material_spinner_sample_layout);

        initSpinner();
    }

    private void initSpinner() {
        spProvince = findViewById(R.id.sp_provinces);
        spEmptyItem = findViewById(R.id.sp_empty_item);
        provinceList = new ArrayList<>();

        provinceList.add("Kampong Thom");
        provinceList.add("Kampong Cham");
        provinceList.add("Kampong Chhnang");
        provinceList.add("Phnom Penh");
        provinceList.add("Kandal");
        provinceList.add("Kampot");

        spProvince.setItem(provinceList);

        spProvince.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
                Toast.makeText(MainActivity.this, provinceList.get(position), Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {
            }
        });
    }
}

In Kotlin class

import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.chivorn.resourcemodule.R
import com.chivorn.smartmaterialspinner.SmartMaterialSpinner


class MainActivity : AppCompatActivity() {
    private var spProvince: SmartMaterialSpinner<String>? = null
    private var spEmptyItem: SmartMaterialSpinner<String>? = null
    private var provinceList: MutableList<String>? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.smart_material_spinner_sample_layout)

        initSpinner()
    }

    private fun initSpinner() {
        spProvince = findViewById(R.id.sp_provinces)
        spEmptyItem = findViewById(R.id.sp_empty_item)
        provinceList = ArrayList()

        provinceList?.add("Kampong Thom")
        provinceList?.add("Kampong Cham")
        provinceList?.add("Kampong Chhnang")
        provinceList?.add("Phnom Penh")
        provinceList?.add("Kandal")
        provinceList?.add("Kampot")

        spProvince?.item = provinceList

        spProvince?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
            override fun onItemSelected(adapterView: AdapterView<*>, view: View, position: Int, id: Long) {
                Toast.makeText(this@MainActivity, provinceList!![position], Toast.LENGTH_SHORT).show()
            }

            override fun onNothingSelected(adapterView: AdapterView<*>) {}
        }
    }
}

Issue and new feature request

Note

Each raised issue, should be provided with some information to be easy for me to replicate it like Device Model, Android version and log message or file

Where to report issue and new feature request

You can create issue on Github to record issue history then to make it fast alert to me, you can send me email or post to Facebook group for any discussion

Contribution

If you want to contribute in this library, please fork this repository and create pull request.

Contributors

<a href="https://github.com/Chivorns/SmartMaterialSpinner/graphs/contributors"> <img src="https://contrib.rocks/image?repo=Chivorns/SmartMaterialSpinner" /> </a>

Made with contributors-img.

License

   Copyright [2018] [Chivorn]

   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.