Create a dropdown list and select different options
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/spinnerItemStyle"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:textSize="20dp"
android:gravity="center"
android:text="Testing" />
//not sure if TextView can be encompassed in Relative/Linear Layout or not
- Implement AdapterView.OnItemSelectedListener -> generates two methods
Spinner optionsSpinner;
String[] options = { "Option 1", "Option 2"};
//to modify dropdown settings, create a custom simple_spinner_item
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, options);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
optionsSpinner.setAdapter(adapter);
optionsSpinner.setOnItemSelectedListener(this);
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
//changes color of selected item only
TextView text = (TextView)view;
text.setTextColor(Color.BLUE);
if (i == 0)
//perform action 1
if (i == 1)
//perform action 2
}