How to remove text that appears in android spinner control?

By default, text appears that appears on the spinner control ... this text is the first value in the array that I linked to the adapter for the counter.

Once selected, this text changes to the value I selected.

I want to remove this text that appears in the spinner control. How should I do it?

0
source share
2 answers

add new class

public class MySpinner extends Spinner {

    private Context _context;

    public MySpinner(Context context, AttributeSet attrs) {
        super(context, attrs);
        _context = context;
    }

    public MySpinner(Context context) {
        super(context);
        _context = context;
    }

    public MySpinner(Context context, AttributeSet attrs, int defStyle) {
        super(context);
        _context = context;
    }

    @Override
    public View getChildAt(int index) {
        View v = new View(_context);
        return v;
    }

}

in your layout

<[package].MySpinner android:id="@+id/Spinner01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
+1
source

To hide the selected text when the counter is "closed", you must define a custom adapter and layout. To understand what it is, I suggest you read this blog post .

, :

+2

Source: https://habr.com/ru/post/1790663/


All Articles