xXNicolaXx
Lurker
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"):
And that's the xml wich contains the spinner:
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.
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) {
}
});
}
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"
/>
Last edited: