Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok,i have done this by using navigationlist instead of manually adding spinner in menu.xml:</p> <p><strong>1. Items require in list must define in array.xml as:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string-array name="dashboardItemList"&gt; &lt;item&gt;Dashboard&lt;/item&gt; &lt;item&gt;Downloads&lt;/item&gt; &lt;item&gt;Revenues&lt;/item&gt; &lt;item&gt;Ads&lt;/item&gt; &lt;item&gt;Rankings&lt;/item&gt; &lt;item&gt;Reviews&lt;/item&gt; &lt;item&gt;Events&lt;/item&gt; &lt;/string-array&gt; &lt;/resources&gt; </code></pre> <p><strong>2. Call navigationList Method in on createMenuOption</strong></p> <p>@Override</p> <pre><code>public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.main_menu, menu); setNavigationList(); return super.onCreateOptionsMenu(menu); } </code></pre> <p><strong>3. Define NavigationMethod,and get strings arrays from array.xml. And set built in layout sherlock_spinner_dropdown_item for NavigationMode.</strong></p> <pre><code>public void setNavigationList() { arrayItemsForDropdown = getResources().getStringArray(R.array.dashboardItemList); Context context = getSupportActionBar().getThemedContext(); ArrayAdapter&lt;CharSequence&gt; list = ArrayAdapter.createFromResource(context,R.array.dashboardItemList, R.layout.sherlock_spinner_item); list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(list, this); } </code></pre> <p>** 4. Now give implementation as per your choice in onNavigationItemSelected Method **</p> <pre><code>@Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { if (arrayItemsForDropdown[itemPosition].equals("Dashboard")) { downloadIcon.setVisible(false); DashboardFragment dashboardFragment = new DashboardFragment(); showFragment(R.id.fragmentContainer, dashboardFragment, "dashboard"); overridePendingTransition(R.anim.right_in, R.anim.right_out); } else if (arrayItemsForDropdown[itemPosition].equals("Downloads")) { Log.d("Spinner", "downloadClicked"); showProgressDialog(); new Thread(new Runnable() { public void run() { checkDownloadsData(); } }).start(); } // skipping further else parts..... return true; } </code></pre> <p>:) And navigationlist bydefault align to left in ActionBarSherlock. Check snapshot.</p> <p><img src="https://i.stack.imgur.com/q2cKY.png" alt="enter image description here"></p>
 

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