Note that there are some explanatory texts on larger screens.

plurals
  1. POMore than one CustomView in ActionBar
    primarykey
    data
    text
    <p>I finally managed to get an ICS styled spinner into an Android 2.3.x ActionBar of my Tabbed Navigation Sherlock Fragment using this code:</p> <pre><code>ActionBar bar = getSherlockActivity().getSupportActionBar(); bar.setDisplayHomeAsUpEnabled(true); int dropDownStyle = R.attr.actionDropDownStyle; ArrayAdapter&lt;String&gt; someAdapter = new ArrayAdapter&lt;String&gt;(getSherlockActivity() .getSupportActionBar().getThemedContext(), R.layout.sherlock_spinner_dropdown_item, new String[] { "Last 7 days", "Last month", "Last 6 months", "Last year" }); IcsSpinner mySpinner = new IcsSpinner(getActivity(), null, dropDownStyle); mySpinner.setAdapter(someAdapter); mySpinner.setOnItemSelectedListener(new IcsAdapterView.OnItemSelectedListener() { @Override public void onItemSelected(IcsAdapterView&lt;?&gt; parent, View view, int position, long id) { switch (position) { //do stuff } } @Override public void onNothingSelected(IcsAdapterView&lt;?&gt; parent) { // simulate a click on the first item of the spinner //do stuff } }); bar.setCustomView(mySpinner); bar.setDisplayShowCustomEnabled(true); </code></pre> <p>Which displays like so:</p> <p><img src="https://i.stack.imgur.com/KFEg2.png" alt="first tab showing ics spinner in 2.3.x"></p> <p>But the next tab along needs to have 2 ICS spinners in the ActionBar. (Previous to using ABS, I had a spinner in the Activity and the options for the second spinner were in a standard options menu.)</p> <p>When I try to add the second CustomView, it overwrites (replaces? overdraws?) the first one (I add both in the second fragment, with different names), like so:</p> <p><img src="https://i.stack.imgur.com/Pv8Cn.png" alt="second tab showing just 1 spinner"></p> <p>Is it possible to have 2 CustomViews in the ActionBar, or am I barking up the wrong tree? How, then, to achieve 2 ICS spinners in the ActionBar?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload