Display icon and title in the ActionBar in Android
<p>I want to display both icon and title in the action bar of an Activity. Here is the screenshot of my app now:</p>

<p><a href="https://i.stack.imgur.com/9Ljvs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Ljvs.png" alt="enter image description here"></a></p>

<p>Now I need the app logo be displayed to the left of MyApp text in the action bar. I have already tried the following code to set the logo but nothing happened:</p>

<pre><code>@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setLogo(R.drawable.ic_launcher_web);
        getSupportActionBar().setDisplayUseLogoEnabled(true);
        setContentView(R.layout.activity_main);

    }
</code></pre>