Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Spinner With Label (Static Text)?

I want to show spinner with static small label above it how it can be possible seen one of the popular app want to show same like it.

Here is my image, red marked one is the spinner with gray colored text above it which does not changes

I don't want to show android:prompt which shows default text inside spinner want to show exact above the spinner in same control

enter image description here

like image 664
Aditi K Avatar asked Dec 31 '13 06:12

Aditi K


2 Answers

That title is nothing but a TextView.

like image 78
Paresh Mayani Avatar answered Nov 15 '22 19:11

Paresh Mayani


for this you will have to create custom spinner:

layout of spinner according to your need name it as custom_spinner:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tVStaticSmallLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="static text"
        android:textColor="#777777"
        android:textSize="22px" />

    <TextView
        android:id="@+id/tVMainText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tVStaticSmallLabel"
        android:layout_marginTop="5dip"
        android:text="your changing text" />
</RelativeLayout> 

in activity give this layout to the spinner:

Spinner mySpinner = (Spinner) findViewById(R.id.yourSpinner);
        mySpinner.setAdapter(new MyAdapter(this, R.layout.custom_spinner,
                spinnerValues));
like image 7
Hamad Avatar answered Nov 15 '22 21:11

Hamad