Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created December 16, 2023 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/46f639bb41dd4f93426141d388a1fc1a to your computer and use it in GitHub Desktop.
Save codeforfun-jp/46f639bb41dd4f93426141d388a1fc1a to your computer and use it in GitHub Desktop.
How to customize spinner
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner = findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
R.layout.custom_spinner,
getResources().getStringArray(R.array.fruit_list)
);
adapter.setDropDownViewResource(R.layout.custom_spinner_dropdown);
spinner.setAdapter(adapter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment