I'm a very beginner. The spinner doesn't work. It didn't use to show arrow when I was just playing with it in design mode, it's not showing text after I implemented it with some code somehow.
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>```
``` Spinner spinner;
ArrayList spinnerArrayList;
ArrayAdapter spinnerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner = findViewById(R.id.spinner);
spinnerArrayList = new ArrayList();
spinnerAdapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item,spinnerArrayList);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
spinnerArrayList.add("Guitar");
spinnerArrayList.add("Drums");
spinnerArrayList.add("Keyboard");
}```
I'm sure these are the standards and basic things, but somehow I'm screwed up
ArrayListafter assigning it to the adapter. By default,Spinnerdoesn't keep a reference to the original list added to the adapter so to retain the changes you should use what has been provided here in this link. - Lalit Fauzdar