Search in sources :

Example 1 with MaterialSpinnerAdapter

use of com.jaredrummler.materialspinner.MaterialSpinnerAdapter in project cythara by gstraube.

the class MainActivity method setTuning.

private void setTuning() {
    final SharedPreferences preferences = getSharedPreferences(PREFS_FILE, MODE_PRIVATE);
    tuningPosition = preferences.getInt(CURRENT_TUNING, 0);
    int textColorDark = getResources().getColor(R.color.colorTextDark);
    MaterialSpinner spinner = findViewById(R.id.tuning);
    MaterialSpinnerAdapter<String> adapter = new MaterialSpinnerAdapter<>(this, Arrays.asList(getResources().getStringArray(R.array.tunings)));
    if (isDarkModeEnabled) {
        spinner.setTextColor(textColorDark);
        spinner.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));
        spinner.setTextColor(textColorDark);
        spinner.setArrowColor(textColorDark);
    }
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    spinner.setSelectedIndex(tuningPosition);
}
Also used : MaterialSpinner(com.jaredrummler.materialspinner.MaterialSpinner) SharedPreferences(android.content.SharedPreferences) MaterialSpinnerAdapter(com.jaredrummler.materialspinner.MaterialSpinnerAdapter)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 MaterialSpinner (com.jaredrummler.materialspinner.MaterialSpinner)1 MaterialSpinnerAdapter (com.jaredrummler.materialspinner.MaterialSpinnerAdapter)1