Note that there are some explanatory texts on larger screens.

plurals
  1. POaction item is not displayed in the actionbar
    primarykey
    data
    text
    <p>No matter, what I do, text is not displayed in the action item along with the image. Can someone please help me with this. Have been struggling with this for few days. </p> <pre><code> public boolean onCreateOptionsMenu(Menu menu) { SubMenu subMenu1 = menu.addSubMenu("Types"); subMenu1.add("type-1"); subMenu1.add("type-2"); subMenu1.add("type-3"); MenuItem subMenu1Item = subMenu1.getItem(); subMenu1Item.setIcon(R.drawable.down_arrow); subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; } </code></pre> <p>In the above code "<strong>Types</strong>" text is not displayed along with the icon. Only icon is displayed. If I remove the <code>subMenu1Item.setIcon(R.drawable.down_arrow);</code> line, then the text is displayed. But I want both. Here I am adding sub menu items to the action item, so that I get dropdown. </p> <p>As I didn't get the suggestions for this <a href="https://stackoverflow.com/questions/14080269/setting-the-dropdown-for-the-action-bar-item">question</a>, I decided to follow at least in this way of adding sub menu items. Here I have two questions.</p> <p><code>1)</code> How to make the text visible along with the icon.</p> <p><code>2)</code> How to listen to the submenuitems' clicks i.e., how do we know when sub items are clicked. When Item is clicked, we can listen in onOptionsItemSelected(MenuItem item), but what is the case for submenu items?</p> <p>If someone can help me on this, I would be very thankful.</p>
    singulars
    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