Search code examples
androidandroid-spinner

How to add prompt to spinner in Android


In my application I want use Spinner and for this a use this library : MaterialSpinner

How can I add android:prompt to this library?

please help me, I need this help


Solution

  • Can take a Look at this library:

    Material Spinner

    Use this dependency in your build.gradle file to reference this library in your project

    compile 'com.github.ganfra:material-spinner:1.1.1'
    

    In the xml :

    <fr.ganfra.materialspinner.MaterialSpinner
            android:id="@+id/spinner"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            app:ms_multiline="false"
            app:ms_dropDownHintView="@layout/my_custom_dropdown_hint_item_layout"
            app:ms_hintView="@layout/my_custom_hint_item_layout""
            app:ms_hint="hint"       
            app:ms_enableFloatingLabel="false"
            app:ms_enableErrorLabel="false"
            app:ms_floatingLabelText="floating label"
            app:ms_baseColor="@color/base"
            app:ms_highlightColor="@color/highlight"
            app:ms_errorColor="@color/error"
            app:ms_typeface="typeface.ttf"
            app:ms_thickness="2dp"
            app:ms_hintColor="@color/hint"
            app:ms_arrowColor="@color/arrow"
            app:ms_arrowSize="16dp"
            app:ms_alignLabels="false"
            app:ms_floatingLabelColor="@color/floating_label"/>
    

    You can set a hint and a floating label text. If no floating label text is provided, the hint will be set instead.