title: How to get the reference of the menu item in onCreate() method
body: <p>I have a menu item on the <code>action bar</code> (Wifi icon).I am able to change the icon with changing the state of the wifi( <code>WIFI_ON</code> and <code>WIFI_OFF</code>), and I can check the state of the wifi on starting of my app in <code>onCreate()</code> method using <code>wifiManager.isWifiEnabled()</code>, but the problem is that I could not set the icon of the menu item in <code>onCreate</code> method.because initially, it will always show the WIFI_OFF icon (no matter wifi is <code>ON</code> or <code>OFF</code>)until the menu item is clicked.</p>
  
  <p>Here is the on onOptionItemSelected() method</p>
  
  <pre><code>case R.id.wifi_status:
              if (!isWifiEnabled) {
                  item.setIcon(R.drawable.wifi_on);
                  wifiManager.setWifiEnabled(true);
                  isWifiEnabled = true;
              } else {
                  item.setIcon(R.drawable.wifi_off);
                  isWifiEnabled = false;
                  wifiManager.setWifiEnabled(false);
              }
              break;
  </code></pre>
  
  <p>This is the Screenshot of the app when activity is start, as this can be seen the wifi button on action bar is off no matter the wifi is <code>ON</code> or <code>OFF</code>
  <a href="https://i.stack.imgur.com/Svcb8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Svcb8.png" alt="Screenshot of the app when activity starts"></a></p>