Android Spinner

Spinner spinner = findViewById(R.id.currency_spinner);

// Create an ArrayAdapter using the String array and a spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
        R.array.spinner_values, R.layout.spinner_item);

// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

// Apply the adapter to the spinner
spinner.setAdapter(adapter);


spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        Log.d("Spinner Demo", "" + parent.getItemAtPosition(position));
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {
        Log.d("Spinner Demo", "Nothing selected");
    }
});