Santiago Carreño
Santiago Carreño

Reputation: 11

How to make an spinner that doesnt allows items to be selected?

Im currently working on an app and im trying to implement a spinner that drops down info (name, age, color) but which doesnt allows to select on the displayed info. Is there a wsy to do this?

Upvotes: 0

Views: 31

Answers (1)

Sarthakpandit
Sarthakpandit

Reputation: 111

you can try this link or use this code from the mentioned link

                Spinner spinner = (Spinner) findViewById(R.id.spinner);

                // Create an ArrayAdapter using the string array and a default spinner layout

                ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.planets_array, android.R.layout.simple_spinner_item);
                // Specify the layout to use when the list of choices appears
                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                // Apply the adapter to the spinner
                spinner.setAdapter(adapter);

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="planets_array">
        <item>Mercury</item>
        <item>Venus</item>
        <item>Earth</item>
        <item>Mars</item>
        <item>Jupiter</item>
        <item>Saturn</item>
        <item>Uranus</item>
        <item>Neptune</item>
    </string-array>
</resources>

Upvotes: 1

Related Questions