Reputation: 5420
I am working on an Android Honeycomb with an ActionBar. I have set up the ActionBar the following way:
// Configures the action bar
private void configureActionBar() {
mActionBar = getActionBar();
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(this, R.array.rooms, android.R.layout.simple_spinner_dropdown_item);
ActionBar.OnNavigationListener navigationCallback = new ActionBar.OnNavigationListener() {
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
String[] rooms = getResources().getStringArray(R.array.rooms);
mAppState.setCurrentRoom(rooms[itemPosition]);
return false;
}
};
mActionBar.setListNavigationCallbacks(spinnerAdapter, navigationCallback);
}
The image below displays a screenshot of a portion of the ActionBar. I would like to style the dropdown list, but am not sure how to do it. This link has some XML samples, but I do not know how to apply them and how to style the specific elements that are pointed out below.
Here's a list of changes that I would like to make:
Does anyone have any ideas on how to do this?
Thank you!
Upvotes: 4
Views: 3210
Reputation: 5420
I found out how to style the items in the list, as well as the displayed item. The solution involved creating two layout xml files in the /res/layout directory - one for the spinner dropdown items, and one for the selector (the displayed item). I was then able to add the view resources to the ArrayAdapter.
R.layout.spinner_dropdown_text_view:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerDropdownTextView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:paddingLeft="10dp"
android:gravity="center_vertical"
android:textSize="18dp" />
R.layout.spinner_selector_text_view:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerSelectorTextView"
android:layout_width="210dp"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:textSize="18dp"
android:textColor="@android:color/black" />
The ArrayAdapter code:
ArrayAdapter<CharSequence> aa = ArrayAdapter.createFromResource(this, R.array.rooms, R.layout.spinner_selector_text_view);
aa.setDropDownViewResource(R.layout.spinner_dropdown_text_view);
The result:
Unfortunately, I was not able to figure out how to add the radio buttons, or how to remove any of the horizontal lines.
Upvotes: 3