Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get icons in my Android image drawer?
    text
    copied!<p>I just created a drawer in my Android app, and now I want to include icons next to each menu item. For this I created a list_item_drawer.xml file, which looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;TextView android:id="@+id/text_drawer_menu_item" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="23dp" android:text="Menu item" /&gt; &lt;ImageView android:id="@+id/image_drawermenu_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/placeholder"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>I then call this file in my MainActivity like so:</p> <pre><code>final String[] menuEntries = {"Overview","New Payment"}; final String[] fragments = { "com.mycompany.fragment.OverviewFragment", "com.mycompany.fragment.DetailsFragment", }; private ActionBarDrawerToggle drawerToggle; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_root); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item_drawer, R.id.text_drawer_menu_item, menuEntries); etc.. </code></pre> <p>The weird thing is, that even though each menu item now has the height of that placeholder image file, I do not see the image file displayed. So my first question: <strong>how do I get the image file to display?</strong></p> <p>But even if that image file is displayed, I wonder (question two), <strong>how do I set a unique icon for each menu item?</strong></p> <p>All tips are welcome!</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