• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Spinner doesn't show any text

Hi again guys,
after LV426 help me with the arraylist problem, now I'm facing a new issue.
When I click on the spinner, I can see all the element of the array, but when I click on one of them, I can't see the name I chose. Even when the activity is created, the spinner doesn't show any default name. The strange think is that I set the height and the width to "wrap content", after I selecting an item on the spinner, it change it size to adapt to the text, but I can't see the text. I try to modify the simple_spinner_item.xml changing the text color to black..but nothing changed. At this point, maybe I miss some code?

That's the method that load the spinner(I call the metod on "OnCreate"):
Java:
public void load_spinner(){
    partecipantsArrayList = getPartecipantsList();
    ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, partecipantsArrayList);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getApplicationContext(),"selected",Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

}
And that's the xml wich contains the spinner:
Code:
<Spinner
    android:id="@+id/partecipants_spinner"
    android:layout_marginStart="20dp"
    android:layout_marginTop="20dp"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:spinnerMode="dropdown"
    />
The spinner show the partecipantsArray element when I click on it, but the, after I select a partecipant from the spinner, it doesn't display anything as I sayd before.
 
Last edited:
Back
Top Bottom