JakeWharton/ActionBarSherlock — Issue #334: NAVIGATION_MODE_LIST & setSelectedNavigationItem
Author: ened
Created: 2012-03-06 10:06:28+00:00
State: open

I'm using the List pattern to switch bet ween different sets of data.

In the Activities (< SherlockFragmentActivity) onCreate method, I'm creating the Menu like this:

``` java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

ActionBar bar = this.getSupportActionBar();

bar.setTitle("Bus Line Stops");
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
bar.setListNavigationCallbacks(new SimpleSpinnerArrayAdapter(this, mFragment.getBusLine()), this);
bar.setSelectedNavigationItem(0);
}
```

The SimpleSpinnerAdapter looks like this:

``` java
class SimpleSpinnerArrayAdapter extends ArrayAdapter implements SpinnerAdapter {
public SimpleSpinnerArrayAdapter(Context ctx, BusLine busLine) {
super(ctx, android.R.layout.simple_spinner_item, new String[]{
ctx.getString(R.string.direction_to_station, busLine.getEndStation().getTranslatedTitle()),
ctx.getString(R.string.direction_to_station, busLine.getStartStation().getTranslatedTitle())
});
this.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}

public View getDropDownView(int position, View convertView, ViewGroup parent) {
return super.getDropDownView(position, convertView, parent);
}
}
```

Unluckily, once open the list in the ActionBar, none of the items is selected. I'm new to the 4.0-wip branch, but it seem to have worked well before the switch.