Making spinner with custom dropdown list
I want to make a Spinner in android which will have the following dropdown list style:
My onCreate method does
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.day, android.R.layout.simple_spinner_item);
and
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
to make the previous image's spinner dropdown list.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.day, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
I followed the instructions from this site . But I don't get the same dropdown list. The setDropDownViewResource and the adapter have no effect.
The only difference i find with the instructions is that the example's style is "android:Theme.Light", while my theme style is Theme.AppCompat.Light. So, i wonder if the AppCompat is the problem.